Learn R Programming

⚠️There's a newer version (1.1.0) of this package.Take me there.

rnaturalearth

An R package to hold and facilitate interaction with Natural Earth map data.

Aims :

  1. access to a pre-downloaded subset of Natural Earth vectors commonly used in world mapping
  2. allow easy subsetting by countries and regions
  3. facilitate download of other Natural Earth vectors
  4. provide a simple, reproducible and sustainable workflow from Natural Earth data to rnaturalearth enabling updating as new versions become available
  5. to clarify differences in world maps classified by countries, sovereign states and map units
  6. 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).

Install rnaturalearth

devtools::install_github("ropenscilabs/rnaturalearth", build_vignettes=TRUE)

First Usage

Here using sp::plot as a simple, quick way to plot maps. Maps could also be made with ggplot2, 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')) 

Introductory vignette

vignette('rnaturalearth', package='rnaturalearth')

To download Natural Earth data not already in the package

Specify the scale, category and 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

vignette('what-is-a-country', package='rnaturalearth')

Reproducible download of Natural Earth data into the package

Script used to get data into the accompanying data packages.

Acknowledgements

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

  1. Country synonyms lookup

  2. Country larger regions lookup

potential additional functions

  1. facilitate joining of user data to country boundaries

  2. facilitate subsetting by country groupings

    • e.g. least developed countries etc.

Copy Link

Version

Install

install.packages('rnaturalearth')

Monthly Downloads

51,298

Version

0.0.0.9000

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Andy South

Last Published

July 28th, 2025

Functions in rnaturalearth (0.0.0.9000)

ne_countries

Get natural earth world country polygons
get_data

Get data from within the package
check_scale

check that this scale is present in Natural Earth
ne_coastline

Get natural earth world coastline
ne_download

download data from Natural Earth and (optionally) read into R
install_rnaturalearthdata

Install the naturalearthdata package after checking with the user
check_rnaturalearthhires

Check whether to install rnaturalearthhires and install if necessary
countries

world country polygons from Natural Earth
check_rnaturalearthdata

Check whether to install rnaturalearthdata and install if necessary
install_rnaturalearthhires

Install the naturalearthhires package after checking with the user
ne_load

rnaturalearth

rnaturalearth : world map data from Natural Earth
ne_file_name

return a natural earth filename based on arguments
ne_states

Get natural earth world state (admin level 1) polygons
check_data_exist

check whether the requested data exist on Natural Earth