Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 610
PAC Avatar asked Jun 12 '14 11:06

PAC


1 Answers

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.

like image 104
Spacedman Avatar answered Oct 04 '22 00:10

Spacedman