If you did not find the geographic information you need in the first propositions of the map section of the gallery, you need to find this information somewhere else, on the web.


The GeoJSON format is a popular format where all the informations are stored in one single file. You can easily read this kind of file with R. It will give you a spatial polygon data frame object. This kind object has several characteristics that make it super handy to work with.


So let’s start by reading a geoJSON file found on the web, giving the boundaries of every French communes.





Note that once you have a spatial object, there are a lot of manipulation you can do with it.  Here a a few manipulation that are often useful. At the end I select only a subset of the data for further plotting:


There are several ways to plot this spatial object. Here are 2 examples using the plot function and the ggplot2 library. Check the explanation of the map section of the gallery to go further!






Leave a Reply

1 Comment threads
0 Thread replies
Most reacted comment
Hottest comment thread
1 Comment authors
Jon Recent comment authors
newest oldest most voted
Notify of

Hello, is it possible to add maps of any country?