Skip to contents

returns world country polygons at a specified scale, or points of tiny_countries

Usage

ne_countries(
  scale = 110,
  type = "countries",
  continent = NULL,
  country = NULL,
  geounit = NULL,
  sovereignty = NULL,
  returnclass = c("sp", "sf")
)

Arguments

scale

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

type

country type, one of 'countries', 'map_units', 'sovereignty', 'tiny_countries'

continent

a character vector of continent names to get countries from.

country

a character vector of country names.

geounit

a character vector of geounit names.

sovereignty

a character vector of sovereignty names.

returnclass

'sp' default or 'sf' for Simple Features

Value

SpatialPolygonsDataFrame,SpatialPointsDataFrame or sf

Examples

spdf_world <- ne_countries()
spdf_africa <- ne_countries(continent = 'africa')
spdf_france <- ne_countries(country = 'france')

if (require(sp)) {
  plot(spdf_world)
  plot(spdf_africa)
  plot(spdf_france)
}
#> Warning: CRS object has no comment
#> Warning: CRS object has no comment

#> Warning: CRS object has no comment



# get as sf
if (require(sf)) { 
  sf_world <- ne_countries(returnclass='sf')
  plot(sf_world)
}
#> Loading required package: sf
#> Linking to GEOS 3.10.2, GDAL 3.4.1, PROJ 8.2.1; sf_use_s2() is TRUE
#> Warning: plotting the first 10 out of 94 attributes; use max.plot = 94 to plot all


if (require(rnaturalearthdata) & require(sp)) {
  spdf_tiny_countries <- ne_countries(type = 'tiny_countries', scale = 50) 
  plot(spdf_tiny_countries)  
}
#> Loading required package: rnaturalearthdata
#> 
#> Attaching package: ‘rnaturalearthdata’
#> The following object is masked from ‘package:rnaturalearth’:
#> 
#>     countries110
#> Warning: CRS object has no comment