[gdal-dev] Question: is there a way to set the TileMatrix value (aka Tile Zoom Level) for GDAL_WMTS?
Even Rouault
even.rouault at spatialys.com
Tue Nov 22 13:12:26 PST 2016
The TileLevel option is not available in the WMTS driver (as not mentionned in
http://gdal.org/frmt_wmts.html)
Looking at,
$ gdalinfo test.xml
Driver: WMTS/OGC Web Mab Tile Service
Files: test.xml
Size is 51220, 32712
Coordinate System is:
PROJCS["WGS 84 / Pseudo-Mercator",
GEOGCS["WGS 84",
DATUM["WGS_1984",
SPHEROID["WGS 84",6378137,298.257223563,
AUTHORITY["EPSG","7030"]],
AUTHORITY["EPSG","6326"]],
PRIMEM["Greenwich",0,
AUTHORITY["EPSG","8901"]],
UNIT["degree",0.0174532925199433,
AUTHORITY["EPSG","9122"]],
AUTHORITY["EPSG","4326"]],
PROJECTION["Mercator_1SP"],
PARAMETER["central_meridian",0],
PARAMETER["scale_factor",1],
PARAMETER["false_easting",0],
PARAMETER["false_northing",0],
UNIT["metre",1,
AUTHORITY["EPSG","9001"]],
AXIS["X",EAST],
AXIS["Y",NORTH],
EXTENSION["PROJ4","+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0
+x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs"],
AUTHORITY["EPSG","3857"]]
Origin = (-9662904.575207639485598,4329581.393627353012562)
Pixel Size = (0.298582141647579,-0.298582141647579)
Metadata:
TITLE=USGSShadedReliefOnly
Image Structure Metadata:
INTERLEAVE=PIXEL
Corner Coordinates:
Upper Left (-9662904.575, 4329581.394) ( 86d48'12.06"W, 36d12'36.67"N)
Lower Left (-9662904.575, 4319814.175) ( 86d48'12.06"W, 36d 8'21.70"N)
Upper Right (-9647611.198, 4329581.394) ( 86d39'57.48"W, 36d12'36.67"N)
Lower Right (-9647611.198, 4319814.175) ( 86d39'57.48"W, 36d 8'21.70"N)
Center (-9655257.887, 4324697.784) ( 86d44' 4.77"W, 36d10'29.21"N)
Band 1 Block=128x128 Type=Byte, ColorInterp=Red
Overviews: 25610x16356, 12805x8178, 6402x4089, 3201x2044, 1601x1022,
800x511, 400x256, 200x128
Mask Flags: PER_DATASET ALPHA
Overviews of mask band: 25610x16356, 12805x8178, 6402x4089, 3201x2044,
1601x1022, 800x511, 400x256, 200x128
Band 2 Block=128x128 Type=Byte, ColorInterp=Green
Overviews: 25610x16356, 12805x8178, 6402x4089, 3201x2044, 1601x1022,
800x511, 400x256, 200x128
Mask Flags: PER_DATASET ALPHA
Overviews of mask band: 25610x16356, 12805x8178, 6402x4089, 3201x2044,
1601x1022, 800x511, 400x256, 200x128
Band 3 Block=128x128 Type=Byte, ColorInterp=Blue
Overviews: 25610x16356, 12805x8178, 6402x4089, 3201x2044, 1601x1022,
800x511, 400x256, 200x128
Mask Flags: PER_DATASET ALPHA
Overviews of mask band: 25610x16356, 12805x8178, 6402x4089, 3201x2044,
1601x1022, 800x511, 400x256, 200x128
Band 4 Block=128x128 Type=Byte, ColorInterp=Alpha
Overviews: 25610x16356, 12805x8178, 6402x4089, 3201x2044, 1601x1022,
800x511, 400x256, 200x128
One can see that the resolution of the full resolution dataset is
0.298582141647579 m/pixel.
This indeed corresponds to zoom level =
>>> math.log((2 * 20037508.3427892 / 256) / 0.298582141647579)/math.log(2)
19.00000000044158
So if you want to query at zoom level 15, you need to select the 5th overview
(the one of size 1601x1022) :
$ gdal_translate -outsize 1601 1022 --debug HTTP test.xml out.tif
[...]
HTTP: Requesting [1/7] https://basemap.nationalmap.gov/arcgis/rest/services/
USGSShadedReliefOnly/MapServer/WMTS/tile/1.0.0/USGSShadedReliefOnly/default/
default028mm/14/6424/4241.jpg
HTTP: Requesting [2/7] https://basemap.nationalmap.gov/arcgis/rest/services/
USGSShadedReliefOnly/MapServer/WMTS/tile/1.0.0/USGSShadedReliefOnly/default/
default028mm/14/6424/4242.jpg
[...]
Or equivalently use the OVERVIEW_LEVEL open option ( see
http://www.gdal.org/classGDALDataset.html#a9cb8585d0b3c16726b08e25bcc94274a )
$ gdal_translate -oo OVERVIEW_LEVEL=4 --debug HTTP test.xml out.tif
Or equivalently, download http://basemap.nationalmap.gov/arcgis/rest/services/
USGSShadedReliefOnly/MapServer/WMTS/1.0.0/WMTSCapabilities.xml locally.
Edit it to remove all TileMatrix > 14.
And refer to this file as the <GetCapabilitiesUrl> .
$ gdalinfo test.xml
Driver: WMTS/OGC Web Mab Tile Service
Files: test.xml
Size is 1601, 1023
Coordinate System is:
PROJCS["WGS 84 / Pseudo-Mercator",
GEOGCS["WGS 84",
DATUM["WGS_1984",
SPHEROID["WGS 84",6378137,298.257223563,
AUTHORITY["EPSG","7030"]],
AUTHORITY["EPSG","6326"]],
PRIMEM["Greenwich",0,
AUTHORITY["EPSG","8901"]],
UNIT["degree",0.0174532925199433,
AUTHORITY["EPSG","9122"]],
AUTHORITY["EPSG","4326"]],
PROJECTION["Mercator_1SP"],
PARAMETER["central_meridian",0],
PARAMETER["scale_factor",1],
PARAMETER["false_easting",0],
PARAMETER["false_northing",0],
UNIT["metre",1,
AUTHORITY["EPSG","9001"]],
AXIS["X",EAST],
AXIS["Y",NORTH],
EXTENSION["PROJ4","+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0
+x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs"],
AUTHORITY["EPSG","3857"]]
Origin = (-9662911.140854565426707,4329584.374663999304175)
Pixel Size = (9.554628535632952,-9.554628535632952)
Metadata:
TITLE=USGSShadedReliefOnly
Image Structure Metadata:
INTERLEAVE=PIXEL
Corner Coordinates:
Upper Left (-9662911.141, 4329584.375) ( 86d48'12.27"W, 36d12'36.75"N)
Lower Left (-9662911.141, 4319809.990) ( 86d48'12.27"W, 36d 8'21.59"N)
Upper Right (-9647614.181, 4329584.375) ( 86d39'57.57"W, 36d12'36.75"N)
Lower Right (-9647614.181, 4319809.990) ( 86d39'57.57"W, 36d 8'21.59"N)
Center (-9655262.661, 4324697.182) ( 86d44' 4.92"W, 36d10'29.20"N)
Band 1 Block=128x128 Type=Byte, ColorInterp=Red
Overviews: 801x512, 400x256, 200x128
Mask Flags: PER_DATASET ALPHA
Overviews of mask band: 801x512, 400x256, 200x128
Band 2 Block=128x128 Type=Byte, ColorInterp=Green
Overviews: 801x512, 400x256, 200x128
Mask Flags: PER_DATASET ALPHA
Overviews of mask band: 801x512, 400x256, 200x128
Band 3 Block=128x128 Type=Byte, ColorInterp=Blue
Overviews: 801x512, 400x256, 200x128
Mask Flags: PER_DATASET ALPHA
Overviews of mask band: 801x512, 400x256, 200x128
Band 4 Block=128x128 Type=Byte, ColorInterp=Alpha
Overviews: 801x512, 400x256, 200x128
Even
--
Spatialys - Geospatial professional services
http://www.spatialys.com
More information about the gdal-dev
mailing list