I downloaded a geojson file of Iraq's electrical grid from EnergyData. You can download the file yourself here:
and visit the webpage here:
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.