Read Mapbox Vector Tile for layer described by info, specified zoom, row, and column from a GeoServer and return as an sf object.
Arguments
- info
layer info for target layer, from
layer.info()
- zoom
zoom level
- row, col
tile row and column (from
get.tile()
)
Details
This uses the URL in the MVT object created by layer.info to produce a URL for the specified row and column at the specified zoom level to fetch the MVT data from a GeoServer and return the data as an sf object.
Note that this functions requires protolite >= 2.2.1. If it's not yet up on CRAN, you can get it with
remotes::install_github('jeroen/protolite')
Author
Bradley W. Compton bcompton@umass.edu
Examples
require(readMVT)
require(leaflet)
#> Loading required package: leaflet
xml <- read.XML('https://umassdsl.webgis1.com/geoserver')
info <- layer.info(xml, 'DEPMEP:streams')
#> Error in layer.info(xml, "DEPMEP:streams"): Error in readMVT: layer DEPMEP:streams is missing
rc <- get.tile(12, 42.394, -72.5312)
x <- read.tile(info, 12, rc[1], rc[2])
#> Error in eval(expr, envir, enclos): object 'info' not found
leaflet(x) |> addTiles() |> addPolylines(data = x)
#> Error in eval(expr, envir, enclos): object 'x' not found