Issues a GetMap request and returns the rendered image georeferenced as a
terra::SpatRaster. Unlike a WFS read this gives you the server's own
cartography — useful for basemaps, orthophotos and any layer published only
as a picture.
Usage
argentum_read_wms(
x,
layer,
bbox,
crs = NULL,
width = NULL,
height = NULL,
style = NULL,
format = NULL,
transparent = TRUE,
quiet = arg_opt("argentum.quiet")
)Arguments
- x
An organization name from
argentum_organizations(), or a WMS URL.- layer
Layer name, or a character vector of names to be drawn in order, first at the bottom.
- bbox
Extent to render, as
c(xmin, ymin, xmax, ymax)or any object accepted bysf::st_bbox(). Required: WMS has no "everything" request.- crs
CRS of
bboxand of the output, e.g."EPSG:4326"or4326. Defaults to"EPSG:4326", or to the CRS ofbboxif it carries one.- width, height
Image size in pixels. If only one is given, the other is derived from the aspect ratio of
bbox. If neither is given,widthdefaults to 800.- style
Optional named style, or one per layer.
- format
MIME type to request.
NULL(default) negotiates one from the formats the service advertises forGetMap, preferring PNG, which keeps transparency. Pass a value such as"image/jpeg"to force it.- transparent
Request a transparent background.
- quiet
Suppress progress messages.
Value
A terra::SpatRaster with the CRS set, ready to combine with
vector data read via argentum_read_wfs().
See also
argentum_wms_legend() for the matching legend graphic.
Examples
# \donttest{
r <- argentum_read_wms(
"https://wms.ign.gob.ar/geoserver/ows",
layer = "ign:provincia",
bbox = c(-59, -35, -57, -34),
width = 800
)
#> Requesting WMS 1.3.0 capabilities from <https://wms.ign.gob.ar/geoserver/ows>
#> ℹ Rendering ign:provincia at 800x400
#> Warning: [rast] unknown extent
#> ✔ Rendered 4 bands.
#> ℹ Rendering ign:provincia at 800x400
#> ✔ Rendering ign:provincia at 800x400 [565ms]
#>
terra::plotRGB(r)
# }
