An R package to hold and facilitate interaction with Natural Earth map data.
- access to a pre-downloaded subset of Natural Earth vectors commonly used in world mapping
- allow easy subsetting by countries and regions
- facilitate download of other Natural Earth vectors
- provide a simple, reproducible and sustainable workflow from Natural Earth data to rnaturalearth enabling updating as new versions become available
- to clarify differences in world maps classified by countries, sovereign states and map units
- to follow Natural Earth naming conventions so that rnaturalearth users can use Natural Earth documentation
The Natural Earth website structures vector data by scale, category and type. These determine the filenames of downloads. rnaturalearth uses this structure to facilitate download (like an API).
You can install the development version from GitHub using devtools.
Data to support much of the package functionality are stored in a data package that you will be prompted to install when required if you do not do so here.
sp::plot as a simple, quick way to plot maps. Maps could also be made with
tmap or other options.
library(rnaturalearth) library(sp) #world countries sp::plot(ne_countries())
#uk sp::plot(ne_countries(country = 'united kingdom'))
#states, admin level1 boundaries sp::plot(ne_states(country = 'spain'))
To download Natural Earth data not already in the package
type of the vector you want. For example for
scale = 50 and
category = 'physical' the available options for
type can be found here. Examples :
#lakes lakes110 <- ne_download(scale = 110, type = 'lakes', category = 'physical') plot(lakes110) #rivers rivers50 <- ne_download(scale = 50, type = 'rivers_lake_centerlines', category = 'physical') plot(rivers50)
Details of different country definitions and scales
Reproducible download of Natural Earth data into the package
Script used to get data into the accompanying data packages.
Thanks to Lincoln Mullen for code structure inspiration from USAboundaries, Hadley Wickham for comments and prompting, Bob Rudis for answers to stackoverflow questions about downloading Natural Earth data into R. The Natural Earth team and Nathan Kelso for providing such a great resource.
Potential future work
potential additional data
Country synonyms lookup
- dataframe with ISO3 and country synonyms
- similar to https://github.com/AndySouth/rworldmap/blob/master/data/countrySynonyms.rda
Country larger regions lookup
- dataframe with ISO3 and membership of different regional groupings, e.g. continent, least developed countries etc.
- similar to https://github.com/AndySouth/rworldmap/blob/master/data/countryRegions.rda
potential additional functions
facilitate joining of user data to country boundaries
- similar to https://github.com/AndySouth/rworldmap/blob/master/R/joinCountryData2Map.R
- ... but with a better name
- similar allowing of join by ISO codes or names, with attempted synonym matching
- similar reporting of country joining success and failure
facilitate subsetting by country groupings
- e.g. least developed countries etc.