Download an RGB raster layer from IGN Web Map Tile Services (WMTS). WMTS focuses on performance and can only query pre-calculated tiles.
Usage
get_wmts(x,
layer = "ORTHOIMAGERY.ORTHOPHOTOS",
zoom = 10L,
crs = 2154,
filename = tempfile(fileext = ".tif"),
verbose = FALSE,
overwrite = FALSE,
interactive = FALSE)
Arguments
- x
Object of class
sf
orsfc
. Needs to be located in France.- layer
character
; layer name fromget_layers_metadata(apikey, "wms")
or directly from IGN website.- zoom
integer
between 0 and 21; at low zoom levels, a small set of map tiles covers a large geographical area. In other words, the smaller the zoom level, the less precise the resolution. For conversion between zoom level and resolution see WMTS IGN Documentation- crs
numeric
,character
, or object of classsf
orsfc
. It is set to EPSG:2154 by default. Seesf::st_crs()
for more detail.- filename
character
orNULL
; filename or a open connection for writing. (ex : "test.tif" or "~/test.tif"). IfNULL
,layer
is used as filename. Default drivers is ".tif" but all gdal drivers are supported, see details for more info.- verbose
boolean
; if TRUE, message are added.- overwrite
If TRUE, output raster is overwrite.
- interactive
logical
; If TRUE, interactive menu ask forapikey
andlayer
.
Examples
if (FALSE) { # \dontrun{
library(sf)
library(tmap)
penmarch <- read_sf(system.file("extdata/penmarch.shp", package = "happign"))
# Get orthophoto
layers <- get_layers_metadata("wmts", "ortho")$Identifier
ortho <- get_wmts(penmarch, layer = layers[1], zoom = 21)
plotRGB(ortho)
# Get all available irc images
layers <- get_layers_metadata("wmts", "orthohisto")$Identifier
irc_names <- grep("irc", layers, value = TRUE, ignore.case = TRUE)
irc <- lapply(irc_names, function(x) get_wmts(penmarch, layer = x, zoom = 18)) |>
setNames(irc_names)
# remove empty layer (e.g. only NA)
irc <- Filter(function(x) !all(is.na(values(x))), irc)
# plot
all_plots <- lapply(irc, plotRGB)
} # }