Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dealing with nested json columns after reading with geojsonsf #97

Open
frabau1 opened this issue Jan 3, 2023 · 2 comments
Open

dealing with nested json columns after reading with geojsonsf #97

frabau1 opened this issue Jan 3, 2023 · 2 comments

Comments

@frabau1
Copy link

frabau1 commented Jan 3, 2023

I'm working with a geojson file and reading it with geojsonsf. The file is importing successfully, but there are still nested json columns in the data frame. I'm not sure this is an issue with the geojsonsf package, but wanted to see if the team had any suggestions on how to unnest the additional columns.

library(geojsonsf)

link <- 'https://tiles.skimap.org/geojson/ski_areas.geojson'

S0 <- geojson_sf(link, expand_geometries = TRUE) 
@dcooley
Copy link
Collaborator

dcooley commented Jan 3, 2023

please see this issue - I initially decided to follow {sf}'s lead and convert nested properties in to strings. And I'm not sure if an {sf} object can handle nested / list columns.

A work-around is something like

lst <- jsonify::from_json(link)

coords <- lst$features$geometry$coordinates

sfc_points <- sfheaders::sf_point(matrix(unlist(coords), ncol = 2, byrow = T))

lst$geometry <- sfc_points

@frabau1
Copy link
Author

frabau1 commented Jan 5, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants