library(maptiles)
library(sf)
nc = st_read(system.file("shape/nc.shp", package = "sf"))
## let's say we have target raster
rr <- get_tiles(
sf::st_transform(nc, "EPSG:3857"),
provider = "OpenStreetMap",
zoom = 7,
crop = TRUE,
forceDownload = TRUE,
project = TRUE
)
rr <- rr * 0
## the tile server configured like this
dsn <- "<GDAL_WMS><Service name=\"TMS\"><ServerUrl>https://tile.openstreetmap.org/${z}/${x}/${y}.png</ServerUrl></Service><DataWindow><UpperLeftX>-20037508.34</UpperLeftX><UpperLeftY>20037508.34</UpperLeftY><LowerRightX>20037508.34</LowerRightX><LowerRightY>-20037508.34</LowerRightY><TileLevel>18</TileLevel><TileCountX>1</TileCountX><TileCountY>1</TileCountY><YOrigin>top</YOrigin></DataWindow><Projection>EPSG:3857</Projection><BlockSizeX>256</BlockSizeX><BlockSizeY>256</BlockSizeY><BandsCount>3</BandsCount><UserAgent>RUser</UserAgent><Cache /></GDAL_WMS>"
im <- terra::project(terra::rast(dsn), rr, by_util = TRUE, method = "bilinear")
terra::plotRGB(im)
plot(sf::st_transform(nc, "EPSG:3857"), add = TRUE, col = NA)
Created
February 17, 2025 21:42
-
-
Save mdsumner/600f751bee6698cf5ca90fe26203433f to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
now see that we get a degraded image (though the size isn't very different), so I think it's a real problem for tmap