Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

ne_download

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


Description

returns downloaded data as a spatial object or the filename if load=FALSE. if destdir is specified the data can be reloaded in a later R session using ne_load with the same arguments.

Usage

ne_download(scale = 110, type = "countries", category = c("cultural",
  "physical", "raster"), destdir = tempdir(), load = TRUE,
  returnclass = c("sp", "sf"))

Arguments

scale

scale of map to return, one of 110, 50, 10 or 'small', 'medium', 'large'

type

type of natural earth file to download one of 'countries', 'map_units', 'map_subunits', 'sovereignty', 'states' OR the portion of any natural earth vector url after the scale and before the . e.g. for 'ne_50m_urban_areas.zip' this would be 'urban_areas'. See Details. OR the raster filename e.g. for 'MSR_50M.zip' this would be 'MSR_50M'

category

one of natural earth categories : 'cultural', 'physical', 'raster'

destdir

where to save files, defaults to tempdir(), getwd() is also possible.

load

TRUE/FALSE whether to load file into R and return

returnclass

'sp' default or 'sf' for Simple Features

Details

A non-exhaustive list of datasets available according to scale specified by the type param

scale = 'small' scale = 'medium' scale = 'large'
category = 'physical', type = '[below]'
coastline y y y
land y y y
ocean y y y
rivers_lake_centerlines y y y
lakes y y y
glaciated_areas y y y
antarctic_ice_shelves_polys - y y
geographic_lines y y y
graticules_1 y y y
graticules_30 y y y
wgs84_bounding_box y y y
playas - y y
minor_islands - - y
reefs - - y
category = 'cultural', type = '[below]'
populated_places y y y
boundary_lines_land y y y
breakaway_disputed_areas - y y
airports - y y
ports - y y
urban_areas - y y
roads - - y
railroads - - y

Value

A Spatial object depending on the data (points, lines, polygons or raster), unless load=FALSE in which case it returns the name of the downloaded shapefile (without extension).

See Also

ne_load, pre-downloaded data are available using ne_countries, ne_states. Other geographic data are available in the raster package : getData.

Examples

## Not run: 
spdf_world <- ne_download( scale = 110, type = 'countries' )

if (require(sp)) {
  plot(spdf_world)
  plot(ne_download(type = 'populated_places'))
}

# reloading from the saved file in the same session with same arguments
spdf_world2 <-    ne_load( scale = 110, type = 'countries' )

# download followed by load from specified directory will work across sessions
spdf_world <- ne_download( scale = 110, type = 'countries', destdir = getwd() )
spdf_world2 <-    ne_load( scale = 110, type = 'countries', destdir = getwd() )

# for raster, here an example with Manual Shaded Relief (MSR)
# download & load
rst <- ne_download(scale = 50, type = 'MSR_50M', category = 'raster', destdir = getwd())

# load after having downloaded
rst <- ne_load(scale = 50, type = 'MSR_50M', category = 'raster', destdir = getwd())

# plot
library(raster)
raster::plot(rst)

## End(Not run) # end dontrun

rnaturalearth

World Map Data from Natural Earth

v0.1.0
MIT + file LICENSE
Authors
Andy South [aut, cre]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.