ne2geojson: Convert Natural Earth shapefiles to GeoJSON.

View source: R/ne2geojson.R

ne2geojsonR Documentation

Convert Natural Earth shapefiles to GeoJSON.

Description

A convenience wrapper building on functions readOGR, spTransform, gSimplify, geojson_json, geojson_write to import and convert shapefiles from Natural Earth to GeoJSON format.

Usage

ne2geojson(
  input_filename = "ne_50m_admin_0_countries",
  local = FALSE,
  local_path = ".",
  output_dir = ".",
  output_filename = NULL,
  crs = "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0",
  simplify = FALSE,
  retain = 0.1
)

Arguments

input_filename

Character string specifying the map layer. Default value is 'ne_50m_admin_0_countries'. Do not add the file extension; import assumes that the input file is in '.zip' format. For a full list of available maps, please see Details.

local

Logical specifying whether the input file is located locally or whether the file must be downloaded from Natural Earth. Default value is FALSE. In the case of TRUE, the path to the file must be specified under local_path.

local_path

Character string specifying the path to the local file specified under local. Default value is the current working directory.

output_dir

Character string specifying the path (no trailing '/') to the output directory where the GeoJSON will be saved. Default value is the current working directory.

output_filename

Character string specifying the filename of the output file (no file extension is required). Default value is NULL, and the file will be given the name of the input file.

crs

Character string specifying the coordinate reference system to use. The default value is '+proj=longlat +ellp=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0'.

simplify

Logical specifying whether to simplify the given geometry. Default value is FALSE.

retain

Numerical value between 0 and 1. Smaller values produce greater simplification. Default value is 0.1.

Details

A full list of available maps is provided below. XX specifies the scale, and must be substituted with 10 (1:10m), 50 (1:50m) or 110 (1:110m). The values in square parentheses indicate the scale(s) a map is available in.

CULTURAL MAPS

Administrative level 0 (countries)

  • ne_XXm_admin_0_countries [10m, 50m, 110m]

  • ne_XXm_admin_0_countries_lakes (without boundary lakes) [10m, 50m, 110m]

  • ne_XXm_admin_0_sovereignty [10m, 50m, 110m]

  • ne_XXm_admin_0_tiny_countries [50m, 110m]

  • ne_XXm_admin_0_tiny_countries_scale_rank [50m]

  • ne_XXm_admin_0_map_units [10m, 50m, 110m]

  • ne_XXm_admin_0_map_subunits [10m, 50m]

  • ne_XXm_admin_0_scale_rank [10m, 50m, 110m]

  • ne_XXm_admin_0_scale_rank_minor_islands (with minor islands) [10m]

  • ne_XXm_admin_0_boundary_lines_land (boundary lines) [10m, 50m, 110m]

  • ne_XXm_admin_0_boundary_lines_map_units [10m]

  • ne_XXm_admin_0_boundary_map_units [50m]

  • ne_XXm_admin_0_boundary_lines_maritime_indicator [10m, 50m]

  • ne_XXm_admin_0_pacific_groupings [10m, 50m, 110m]

  • ne_XXm_admin_0_disputed_areas [10m]

  • ne_XXm_admin_0_breakaway_disputed_areas [50m]

  • ne_XXm_admin_0_disputed_areas_scales_rank_minor_islands [10m]

  • ne_XXm_admin_0_boundary_lines_disputed_areas (boundary lines) [10m, 50m]

  • ne_XXm_admin_0_antarctic_claims [10m]

  • ne_XXm_admin_0_antarctic_claim_limit_lines (boundary lines) [10m]

    Administrative level 1 (states/provinces)

  • ne_XXm_admin_1_states_provinces [10m, 110m]

  • ne_XXm_admin_1_states_provinces_scale_rank [10m]

  • ne_XXm_admin_1_states_provinces_shp_scale_rank [50m, 110m]

  • ne_XXm_admin_1_states_provinces_lakes (without large lakes) [10m, 50m, 110m]

  • ne_XXm_admin_1_states_provinces_lines (boundary lines) [10m, 50m, 110m]

    Populated places

  • ne_XXm_populated_places [10m, 50m, 110m]

  • ne_XXm_polulated_places_simple (reduced set) [10m, 50m, 110m]

    Roads and railways

  • ne_XXm_roads [10m]

  • ne_XXm_roads_north_america [10m]

  • ne_XXm_railroads [10m]

  • ne_XXm_railroads_north_america [10m]

    Airports and ports

  • ne_XXm_airports [10m, 50m]

  • ne_XXm_ports [10m, 50m]

    Other

  • ne_XXm_urban_areas [10m, 50m]

  • ne_XXm_parks_and_protected_lands (USA) [10m]

  • ne_XXm_time_zones [10m]

    Cultural building blocks

  • ne_XXm_admin_0_label_points [10m]

  • ne_XXm_admin_0_seams [10m]

  • ne_XXm_admin_1_label_points [10m]

  • ne_XXm_admin_1_seams [10m]

  • ne_XXm_cultural_building_blocks_all (labels and seams) [10m]

    PHYSICAL MAPS

    Coastline

  • ne_XXm_coastline [10m]

    Land

  • ne_XXm_land [10m]

  • ne_XXm_land_scale_rank [10m]

    Minor islands and reefs

  • ne_XXm_minor_islands [10m]

  • ne_XXm_minor_islands_coastline [10m]

  • nn_XXm_reefs [10m]

    Oceans

  • ne_XXm_ocean [10m]

  • ne_XXm_ocean_scale_rank [10m]

    Rivers, lake centerlines, lakes, and resevoirs

  • ne_XXm_rivers_lake_centerlines [10m]

  • ne_XXm_rivers_lake_centerline_scale_rank [10m]

  • ne_XXm_rivers_north_america [10m]

  • ne_XXm_rivers_europe [10m]

  • ne_XXm_lakes [10m]

  • ne_XXm_lakes_historic [10m]

  • ne_XXm_lakes_pluvial [10m]

  • ne_XXm_lakes_north_america [10m]

  • ne_XXm_lakes_europe [10m]

Examples

## Not run: 
# Create 110m scale country-level GeoJSON in current working directory
ne2geojson(input_filename = 'ne_110m_admin_0_countries')

# Create 110m scale country-level GeoJSON in new directory
ne2geojson(input_filename = 'ne_110m_admin_0_countries', output_dir = './country'

# Create simplified 110m scale country-level GeoJSON, retaining 50% of points
ne2geojson(input_filename = 'ne_110m_admin_0_countries', simplify = TRUE, retain = 0.5)

## End(Not run)


kamermanpr/ne2geojson documentation built on Jan. 12, 2023, 6:50 p.m.