Learn R Programming

giscoR (version 0.2.4)

gisco_get_units: Get geospatial units data from GISCO API

Description

Download individual shapefiles of units. Unlike gisco_get_countries(), gisco_get_nuts() or gisco_get_urban_audit(), that downloads a full dataset and applies filters, gisco_get_units() downloads a single shapefile for each unit.

Usage

gisco_get_units(
  id_giscoR = "nuts",
  unit = "ES4",
  mode = "sf",
  year = "2016",
  epsg = "4326",
  cache = TRUE,
  update_cache = FALSE,
  cache_dir = NULL,
  verbose = FALSE,
  resolution = "20",
  spatialtype = "RG"
)

Arguments

id_giscoR

Select the unit type to be downloaded. Accepted values are "nuts", "countries" or "urban_audit".

unit

Unit ID to be downloaded. See Details.

mode

Controls the output of the function. Possible values are "sf" or "df". See Value and Details.

year

Release year. See Release years available on gisco_get.

epsg

projection of the map: 4-digit EPSG code. One of:

  • "4258": ETRS89

  • "4326": WGS84

  • "3035": ETRS89 / ETRS-LAEA

  • "3857": Pseudo-Mercator

cache

A logical whether to do caching. Default is TRUE.

update_cache

A logical whether to update cache. Default is FALSE. When set to TRUE it would force a fresh download of the source .geojson file.

cache_dir

A path to a cache directory. See Details on gisco_get.

verbose

Display information. Useful for debugging, default is FALSE.

resolution

Resolution of the geospatial data. One of

  • "60": 1:60million

  • "20": 1:20million

  • "10": 1:10million

  • "03": 1:3million

  • "01": 1:1million

spatialtype

Type of geometry to be returned: "RG", for POLYGON and "LB" for POINT.

Value

A sf object on mode = "sf" or a dataframe on mode = "df".

Details

The function can return a dataframe on mode = "df" or a sf object on mode = "sf".

In order to see the available unit ids with the required combination of spatialtype, year, first run the function on "df" mode. Once that you get the data frame you can select the required ids on the unit parameter.

On mode = "df" the only relevant parameters are spatialtype, year.

See Also

gisco_get

Examples

Run this code
# NOT RUN {
library(sf)

if (gisco_check_access()) {
  cities <- gisco_get_units(
    id_giscoR = "urban_audit",
    mode = "df",
    year = "2020"
  )
  VAL <- cities[grep("Valencia", cities$URAU_NAME), ]
  #'   Order from big to small
  VAL <- VAL[order(as.double(VAL$AREA_SQM), decreasing = TRUE), ]

  VAL.sf <- gisco_get_units(
    id_giscoR = "urban_audit",
    year = "2020",
    unit = VAL$URAU_CODE
  )
  # Provincia
  Provincia <-
    gisco_get_units(
      id_giscoR = "nuts",
      unit = c("ES523"),
      resolution = "01"
    )

  # Surrounding area
  NUTS1 <-
    gisco_get_units(
      id_giscoR = "nuts",
      unit = c("ES5"),
      resolution = "01"
    )

  # Plot
  plot(
    st_geometry(Provincia),
    col = "gray1",
    border = "grey50",
    lwd = 3
  )
  plot(st_geometry(NUTS1),
    border = "grey50",
    lwd = 3,
    add = TRUE
  )
  plot(
    st_geometry(VAL.sf),
    col = c("deeppink4", "brown2", "khaki1"),
    add = TRUE
  )
  box()
  title(
    "Urban Audit - Valencia (ES)",
    sub = gisco_attributions("es"),
    line = 1,
    cex.sub = 0.7
  )
}
# }

Run the code above in your browser using DataLab