Is it possible to read geoJSON or topoJSON file in R to draw a choropleth map?

PAC picture PAC · Jun 12, 2014 · Viewed 9.2k times · Source

topoJSON and geoJSON files are know very common for drawing maps on the internet. Is it possible to import them in R to draw choropleth maps?

Answer

Spacedman picture Spacedman · Jun 12, 2014

Get the rgdal package installed. Then if:

library(rgdal)
> "GeoJSON" %in% ogrDrivers()$name
[1] TRUE

then you can do something like:

> map = readOGR("foo.json", "OGRGeoJSON")
> plot(map)

But you need GeoJSON support in your ogrDrivers list.