hypertidy / dsn

Data Source Name Helpers for Use With GDAL
https://hypertidy.github.io/dsn/
Other
6 stars 0 forks source link

USGSTopo #6

Open mdsumner opened 1 year ago

mdsumner commented 1 year ago

this came out of quickmapr:

dsn <- "<GDAL_WMTS>\n  <GetCapabilitiesUrl>https://basemap.nationalmap.gov/arcgis/rest/services/USGSTopo/MapServer/WMTS/1.0.0/WMTSCapabilities.xml</GetCapabilitiesUrl>\n  <Layer>USGSTopo</Layer>\n  <Style>default</Style>\n  <TileMatrixSet>default028mm</TileMatrixSet>\n  <DataWindow>\n    <UpperLeftX>-20037507.89491379</UpperLeftX>\n    <UpperLeftY>30240972.21668198</UpperLeftY>\n    <LowerRightX>20038725.61259397</LowerRightX>\n    <LowerRightY>-30242455.26191777</LowerRightY>\n  </DataWindow>\n  <BandsCount>4</BandsCount>\n  <DataType>Byte</DataType>\n  <Cache />\n  <UnsafeSSL>true</UnsafeSSL>\n  <ZeroBlockHttpCodes>204,404</ZeroBlockHttpCodes>\n  <ZeroBlockOnServerException>true</ZeroBlockOnServerException>\n</GDAL_WMTS>"

## works with "vrt://%s?ovr=18"

created with gdal_translate -of WMTS ... x.xml

mdsumner commented 1 year ago

this also works

img <- "vrt://WMTS:https://basemap.nationalmap.gov/arcgis/rest/services/USGSImageryTopo/MapServer/WMTS/1.0.0/WMTSCapabilities.xml,layer=USGSImageryTopo,tilematrixset=default028mm?ovr=6"

pt <- cbind(37.8199286,-122.4782551)[,2:1, drop = FALSE]
terra::plotRGB(terra::project(terra::rast(img), terra::rast(terra::ext(c(-1, 1, -1, 1) * 5e3), ncols = 512, nrows = 512, crs = sprintf("+proj=laea +lon_0=%f +lat_0=%f", pt[1], pt[2]))))

image

and a couple of other layers in there: https://basemap.nationalmap.gov/arcgis/rest/services