R: Working with GeoJSON data and resolve 'Error in ogrInfo'
This blog presents how to work with GeoJSON data in R, and proposes the solution of "Error in ogrInfo(dsn = dsn, layer = layer, encoding = encoding, use_iconv = use_iconv"
Since working in franprix, I’ve accomplished many projects, for different
departments. Thanks to this opportunity, I understood business of various
services and learnt lots of technique of R. Today I’d like to share with you how
to read GeoJSON data in R.
Concerning the dataset, we take the Paris international tourist area
as an example. Then we use either rgdal or geojsonio package, and read it as
following.
Moreover, for reading GeoJSON data, many web sites recommend similar codes but
withoutrequire_geomType parameter, and many people get following errors:
Thanks to stackoverflow, I understood what the error means, and
extract the features that I need.
After confirming with codes above, I could make sure that wkbPolygon is the
parameter needed, so it was added in the codes at the beginning.
This method can be also applied with the result of leaflet(). We can plot some
places in the map with leaflet(), then use addPolygons() to add the
ploygons-layer.