separate read and download tile capabilities
mdsumner opened this issue · 3 comments
mdsumner commented
do any reading straight from the sources with GDAL, way better - ceramic probably just of historical interest
https://gist.github.com/mdsumner/92485d4f6cc198f59d1648e7ee25120f
x <- vapour:::vapour_tilexyz("https://api.mapbox.com/v4/mapbox.terrain-rgb/${z}/${x}/${y}.pngraw?access_token=YOURTOKEN",
tile_level = 15)
writeLines(x) ## let's add the http error codes for empty blocks
x <- '<GDAL_WMS>
<Service name="TMS">
<ServerUrl>https://api.mapbox.com/v4/mapbox.terrain-rgb/${z}/${x}/${y}.pngraw?access_token=YOURTOKEN</ServerUrl>
</Service>
<DataWindow>
<UpperLeftX>-20037508.340000</UpperLeftX>
<UpperLeftY>20037508.340000</UpperLeftY>
<LowerRightX>20037508.340000</LowerRightX>
<LowerRightY>-20037508.340000</LowerRightY>
<TileLevel>15</TileLevel>
<TileCountX>1</TileCountX>
<TileCountY>1</TileCountY>
<YOrigin>top</YOrigin>
</DataWindow>
<Projection>EPSG:3857</Projection>
<BlockSizeX>256</BlockSizeX>
<BlockSizeY>256</BlockSizeY>
<BandsCount>3</BandsCount>
<ZeroBlockHttpCodes>404</ZeroBlockHttpCodes>
<UserAgent>RStudio Server (2022.7.0.548); R (4.2.1 x86_64-pc-linux-gnu x86_64 linux-gnu)</UserAgent>
</GDAL_WMS>'
library(whatarelief)
ex <- c(-1, 1, -1, 1) * 4e5
prj <- "+proj=laea +lon_0=147 +lat_0=-42"
dm <- c(1024, 1024)
arr <- array(unlist(lapply(1:3, \(band) elevation(source = x, bands = band, extent = ex, dimension = dm, projection = prj)),
use.names = FALSE), c(dm, 3L))
#https://docs.mapbox.com/data/tilesets/reference/mapbox-terrain-rgb-v1/#elevation-data
height = -10000 + ((arr[,,1] * 256 * 256 + arr[,,2] * 256 + arr[,,3]) * 0.1)
ximage::ximage(height, extent = ex, asp = 1, col = grey.colors(64), zlim = c(0, max(height)))
mdsumner commented
Actually, I think a better idea will be to keep the read capability, but just decouple it.
We can use vapour here and we can drop rgdal and raster.
mdsumner commented
this is in progress in branch use-gdal
mdsumner commented
done