View source: R/get_wms_raster.R
get_wms_raster | R Documentation |
Download a raster layer from the IGN Web Mapping Services (WMS). Specify a location using a shape and provide the layer name.
get_wms_raster(x,
layer = "ORTHOIMAGERY.ORTHOPHOTOS",
res = 10,
crs = 2154,
rgb = TRUE,
filename = tempfile(fileext = ".tif"),
verbose = TRUE,
overwrite = FALSE,
interactive = FALSE)
x |
Object of class |
layer |
|
res |
|
crs |
|
rgb |
|
filename |
|
verbose |
|
overwrite |
|
interactive |
|
res
: Note that setting res
higher than the default resolution
of the layer will increase the number of pixels but not the precision
of the image. For instance, downloading the BD Alti layer from IGN
is optimal at a resolution of 25m.
rgb
: Rasters are commonly used to download images such as orthophotos.
In specific cases like DEMs, however, a value per pixel is essential.
overwrite
: The function get_wms_raster
first checks if
filename
already exists. If it does, the file is imported into
R without downloading again, unless overwrite
is set to TRUE
.
SpatRaster
object from terra
package.
get_layers_metadata()
## Not run:
library(sf)
library(tmap)
# Shape from the best town in France
penmarch <- read_sf(system.file("extdata/penmarch.shp", package = "happign"))
# For quick testing use interactive = TRUE
raster <- get_wms_raster(x = penmarch, res = 25, interactive = TRUE)
# For specific data, choose apikey with get_apikey() and layer with get_layers_metadata()
apikey <- get_apikeys()[4] # altimetrie
metadata_table <- get_layers_metadata("wms-r", apikey) # all layers for altimetrie wms
layer <- metadata_table[2,1] # ELEVATION.ELEVATIONGRIDCOVERAGE
# Downloading digital elevation model values not image
mnt_2154 <- get_wms_raster(penmarch, layer, res = 1, crs = 2154, rgb = FALSE)
# If crs is set to 4326, res is in degrees
mnt_4326 <- get_wms_raster(penmarch, layer, res = 0.0001, crs = 4326, rgb = FALSE)
# Plotting result
tm_shape(mnt_4326)+
tm_raster()+
tm_shape(penmarch)+
tm_borders(col = "blue", lwd = 3)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.