Search code examples
rdictionaryplotcountry

How to have a precise map of a country with R


I usually went to the site : http://gadm.org to find the contours of the country I wanted to plot with R. But today, this website is closed, and I don't know how to proceed to have a really accurate map...

When I try :

library(maps)
map("world", xlim=c(15,23), ylim=c(45.5,49))

The contours of the country are not very accurate...

I try to find an other website which could give the contours, but I didn't find.

Somebody can help me ?


Solution

  • Ok, let's say you want to plot France contours using data from Natural Earth:

    # First download the data in your working directory
    download.file("http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/cultural/ne_10m_admin_0_countries.zip", "countries.zip")
    # Then unzip
    unzip("countries.zip")
    # Load maptools
    library(maptools)
    # Read in the shapefile
    world <- readShapeSpatial("ne_10m_admin_0_countries.shp")
    # Plot France
    plot(world[world$ADMIN=="France",1]) 
    # Column 1 is the id column, column "ADMIN" contains the country names