Skip to contents

Writes one file per layer and returns a report. Failures are recorded and the run continues, so one broken layer does not abort a bulk download.

Usage

argentum_download(
  x,
  layers = NULL,
  dir = file.path(tempdir(), "argentum"),
  format = c("gpkg", "geojson", "shp"),
  overwrite = FALSE,
  bbox = NULL,
  crs = NULL,
  max_features = NULL,
  quiet = arg_opt("argentum.quiet")
)

Arguments

x

An organization name from argentum_organizations(), or a WFS URL.

layers

Character vector of layer names. NULL (default) downloads every layer the service publishes.

dir

Destination directory. Created if absent. Defaults to a session temporary directory, per CRAN policy on writing to the user's filespace.

format

One of "gpkg" (default), "geojson" or "shp". GeoPackage is recommended: Shapefile truncates field names to ten characters and cannot hold more than 2 GB.

overwrite

Overwrite files that already exist.

bbox

Optional spatial filter. Either a numeric vector c(xmin, ymin, xmax, ymax), or any object accepted by sf::st_bbox(), such as an existing sf object.

crs

Coordinate reference system to request, e.g. "EPSG:4326" or 4326. NULL (default) negotiates one from the layer's declared list, preferring EPSG:4326; if the layer declares none, the server's own default is used.

max_features

Stop after this many features. NULL (default) reads everything.

quiet

Suppress progress messages.

Value

Invisibly, a data frame with one row per layer and columns layer, status ("success", "skipped" or "error"), path, features and message.

Examples

# \donttest{
report <- argentum_download(
  "https://wms.ign.gob.ar/geoserver/ows",
  layers = "ign:provincia",
  dir = tempdir()
)
#>  ign:provincia: 24 features
#> 
#> ── Download summary 
#>  1 succeeded
#>  0 skipped
#>  0 failed
#> Files in /tmp/Rtmp1uV7rN
subset(report, status == "error")
#> [1] layer    status   path     features message 
#> <0 rows> (or 0-length row.names)
# }