how can i read a geojson file using a sf library?

The sf package cannot read geojson natively. However, there is a package called geojsonsf that reads geojson into data that you can work with in sf.

Obviously I don’t have your geojson file to work with, but the package itself comes with some sample data so that I can show you the principle:


geo <- geojson_sf("C:/R/R-3.6.2/library/geojsonsf/examples/geo_melbourne.geojson")

ggplot(geo) + geom_sf(aes(fill = SA2_NAME)) + guides(fill = guide_none())

enter image description here

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top