The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.
An R package to hold and facilitate interaction with Natural Earth map data.
This package provides :
easy subsetting by countries and regions
functions to download other Natural Earth vector and raster data
a simple, reproducible and sustainable workflow from Natural Earth data to rnaturalearth enabling updating as new versions become available
clarification of differences in world maps classified by countries, sovereign states and map units
consistency with Natural Earth naming conventions so that rnaturalearth users can use Natural Earth documentation
data in sf
or sv
formats
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 from CRAN :
or install the development version from GitHub using devtools.
Data to support much of the package functionality are stored in two data packages that you will be prompted to install when required if you do not do so here.
devtools::install_github("ropensci/rnaturalearthdata")
devtools::install_github("ropensci/rnaturalearthhires")
Here using plot
as a simple, quick way to plot maps. Maps could also be made with ggplot2
, tmap
or other options. All retrieval functions accept an argument returnclass = "sf"
to return package sf
(Simple Features) or returnclass = "sv"
(SpatVector) objects.
library(rnaturalearth)
# world countries
plot(ne_countries())
Warning: plotting the first 9 out of 168 attributes; use max.plot = 168 to plot
all
# uk
plot(ne_countries(country = "united kingdom"))
Warning: plotting the first 10 out of 168 attributes; use max.plot = 168 to
plot all
# states, admin level1 boundaries
plot(ne_states(country = "spain"))
Warning: plotting the first 9 out of 121 attributes; use max.plot = 121 to plot
all
There are a wealth of other data available at the Natural Earth website. rnaturalearth
has functions to help with download of these data.
The data available are outlined in the two tables below and online here.
category cultural
category physical
Specify the scale
, category
and type
of the vector you want as in the examples below.
# lakes
lakes110 <- ne_download(scale = 110, type = "lakes", category = "physical")
plot(lakes110)
# rivers
rivers50 <- ne_download(
scale = 50,
type = "rivers_lake_centerlines",
category = "physical",
returnclass = "sf"
)
library(ggplot2)
library(sf)
ggplot(rivers50) +
geom_sf() +
theme_minimal()
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.
facilitate joining of user data to country boundaries
facilitate subsetting by country groupings
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.