geojsonio::geojson_read error for a geojson file "conversion from feature type sfc_GEOMETRY to sp is not supported"

458 Views Asked by At

I downloaded a geojson file of Iraq's electrical grid from EnergyData. You can download the file yourself here:

https://development-data-hub-s3-public.s3.amazonaws.com/ddhfiles/145188/electric-network-iraq.geojson

and visit the webpage here:

https://energydata.info/dataset/iraq-electricity-transmission-network-2017/resource/4a302ef4-0d79-47db-b301-7b40293067b0

I tried to use the library geojsonio to read the file into R, but:

When I set the what argument to what = "sp" it returns the error:

Error in h(simpleError(msg, call)) : error in evaluating the argument 'x' in selecting a method for function 'addAttrToGeom': conversion from feature type sfc_GEOMETRY to sp is not supported

When I set what = "list" I get the error:

Error in rcpp_sf_to_geojson(sf, digits, factors_as_string) : Unknown R object type

When I set what = "json" I get the error:

Error in read_json(x, parse, what, stringsAsFactors, ...) : what='json' not supported for file and url inputs yet

Here's my code:

library(geojsonio)
obj = geojson_read("Filepath/electric-network-iraq.geojson"),
             what = "sp")

I tried alternate code, which just returned an empty string:

library(spData)
obj = system.file("Filepath/electric-network-iraq.geojson",package="spData") 

I know the file isn't actually empty because when I open the file up in Notepad I can see the coordinates of the electrical grid.

This is my first time ever dealing with the geojsonio package, so please be detailed in your response. I just want to read in the powerlines into R as a lines spatial object, but I'm new to these data formats.

0

There are 0 best solutions below