PermafrostDiscoveryGateway / viz-workflow

Processing workflow for visualization
Apache License 2.0
2 stars 2 forks source link

deploy WMTS GetCapabilities response documents #28

Open mbjones opened 1 year ago

mbjones commented 1 year ago

The tiled data products and map tile products produced from viz-workflow conform to the WorldCRS84Quad TileMatrixSet, and so can be described as a [WMTS]()-compliant tileset that can be loaded easily into any GIS system that supports WMTS, such as QGIS and various python libraries. As our tiles are structured and being delivered through a REST API endpoint on our web server, all we need to provide is the GetCapabilities response document that describes the tileset and its layers. These can be provided both for the map tiles in png format, but also for our tiled Geotiff, geopackage, and other format files. WMTS even supports a syntax to describe the same data product with different formats using different resource url formats, so we should discuss how to best arrange our file hierarchies for this.

Attached is a proof of concept for the PNG tiles from the Witharana et al. (https://doi.org/10.18739/A2KW57K57) ice wedge polygon dataset. This response document is installed on our servers at the following url location:

That URL is all that is needed to load the data layer into QGIS or another software platform.

And here is a screenshot showing the layer loaded in QGIS automatically:

image

TODO:

@julietcohen @robyngit @iannesbitt Feedback and other ideas appreciated. Thanks, and let's discuss.

mbjones commented 1 year ago

And here's the same layer viewed in QGIS against the high-res (50cm) RGB imagery form the state of alaska WMTS server (rather than OSM):

image
mbjones commented 10 months ago

While we can produce a WMTS for the entire globe, another consideration might be to create a subsetted WMTS focused on a particular area of interest (AOI) which the user might specify with a polygon in the MetacatUI tool. This would, for example, generate a derived WMTS document that constrains the data layer to the AOI while providing the metadata needed to load the data at mutliple zoom levels in mapping software. This would be a "virtual" subset of the data layer, and might be useful if people want to focus on a specific region and not default to the entire global layer.

yvonnesjy commented 7 months ago

Hey Matt! I've read through the WMTSCapabilities document you linked, with the question of defining an area of interest in mind. Here are some questions:

mbjones commented 7 months ago

@yvonnesjy -- yes, by derived, I simply mean another WMTS that is generated from the full dataset WMTS description and only includes a subset of the data -- that can be via changing the extent, reducing the features list, the tile zoom levels supported, and reducing the formats, among other things, which makes the dataset appear smaller than the original, and constrains the choices.

As I generated the original WMTS by hand just as an example of the format, I might not have matched the smallest bounding box for the IWP data. I was hoping we would automate the production of WMTS metadata during our workflow runs and publish them with the tilesets (probably in the root of the tileset directory).

yvonnesjy commented 7 months ago

Thanks Matt- that makes sense! I also downloaded QGIS and have successfully imported iwp_high through the https://arcticdata.io capabilities url.

My next step is to test out some xml changes locally to understand the schema better. You mentioned a local download of WMTSCapabilities.xml should work equally, but I haven't found a way to specify it as a WMTS connection. Can you show me how?

yvonnesjy commented 7 months ago

Reading QGIS's documentation, I also noticed a potential issue-

WGS 84 Bounding Box — ... Some WMS servers do not set this correctly (e.g., UTM coordinates are used instead). If this is the case, then the initial view of this layer may be rendered with a very ‘zoomed-out’ appearance by QGIS. ...

I wonder if this means that the client (at least QGIS) won't strictly follow a smaller bounding box set by a derived capabilities file, which would explain why I still see the dataset outside of the WGS84BoundingBox you set @mbjones

mbjones commented 7 months ago

@yvonnesjy Could be, I'm not sure. But note the quote talks about WMS services, and not WMTS. WMS is an older specification (still in widespread use) and behaves somewhat differently from WMTS, so I wonder if the same limitations apply there. WMS isn't really a tiling standard (requests are specified in geocoordinates, and return a server-provided map image). SO has an overview of the differences beween WMS and WMTS..

Regarding the larger display extent, that could be a simple artifact of the tiling approach. If the bbox requested 1) doesn't exactly match the boundaries of tiles, or 2) is not the same aspect ratio as the viewport being rendered, then I think most WMTS clients will retrieve all of the tiles needed to cover the bounding box and the viewport, which can be a fair bit larger than the bbox itself. Could this account for what you are seeing?

yvonnesjy commented 7 months ago

AH I have a hypothesis! For your bounding box, @mbjones , I think it actually wraps around the world from -179 to 179, instead of crossing the antimeridian like I assumed. So showing the full dataset is expected:) (But then that begs the question: how do I define the bounding box if I do want it to cross the antimeridian?)

I've verified with a modified capabilities file (through url, haven't found a way to use local capabilities.xml yet) that QGIS handles changes to extent (through ows:WGS84BoundingBox), and zoom levels (through TileMatrixSet) correctly. Here are clarifications to the remainder of your comment:

ianguerin commented 6 months ago

I would be very curious to see a working example of a GetCapabilities response that works with GeoTIFF image type instead of PNGs. So far I've had no luck loading some from a GitHub search, or trying to write my own. I'd like to be able to visualize it in QGIS, and I'm assuming it will be loaded in much the same way as the WMTSGetCapabilities.xml file you, @mbjones , posted above.

I have gotten to the point in QGIS where there is a logged error message

Returned image is flawed [Content-Type: image/tiff; URL: https://arcticdata.io/data/10.18739/A2KW57K57/iwp_geotiff_high/WGS1984Quad/1/3/0.tif]

Which points to a valid tif file, which I can load into QGIS. So it's clearly trying to load various GeoTIFF tiles, but seems to fail in doing so

mbjones commented 6 months ago

@ianguerin The error you cite seems to indicate the TIFF file is not valid. I downloaded 0.tif from the URL you provided at the ADC, and I also have trouble opening it in any application. It is possible the file is not valid, we should explore that with @julietcohen and @robyngit.

I went and looked up a WMTS tileset that supports multiple formats. This example is from SentinelHub (see their API examples). I was able to use QGIS to access their capabilities URL and load a GeoTIFF layer in QGIS, and recolorize it with a palette of my choice.

image

SentinelHub doesn't use the RESTFUL http encoding that we do in our WMTS, and instead use KVP encoding for service access, but it does show how to support multiple formats. The main difference is we need to provide the proper ResourceURL template for our REST approach too. To access SentinelHub, you need an API key to access the service (free, just create an account and a use the SimpleWMS configuration instance id everywhere below where I mention <INSTANCE_ID>).

Here's the capabilities document, which I retrieved with curl but edited out a lot of the details so I could paste it in this issue (there are more layers and TileMatrixSets than I am showing here):

curl -s "https://services.sentinel-hub.com/ogc/wmts/<INSTANCE_ID>?REQUEST=GetCapabilities" > capabilities.xml
capabilties.xml ```xml Sentinel Hub WMTS service - Simple WMS template WMTS 1.0.0 https://www.sentinel-hub.com Sinergise d.o.o. +386 1 320-61-50 +386 1 620-22-28 Cvetkova ulica 29 Ljubljana 1000 Slovenia info@sinergise.com KVP KVP NDVI NDVI -180 -90 180 90 NDVI time ISO8601 2024-05-14 false 1984-03-01/2024-05-14/P1D 150000 1100000 850000 10000000 150000 0 850000 9350000 150000 0 850000 9350000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 0 850000 9350000 150000 0 850000 9350000 150000 1100000 850000 10000000 -120000 -20000 760000 1280000 150000 0 850000 9350000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 0 850000 9350000 150000 0 850000 9350000 150000 1100000 850000 10000000 150000 0 850000 9350000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 0 850000 9350000 150000 0 850000 9350000 -378306 6005280 1320650 7235613 150000 1100000 850000 10000000 150000 0 850000 9350000 150000 0 850000 9350000 150000 0 850000 9350000 150000 1100000 850000 10000000 150000 0 850000 9350000 150000 0 850000 9350000 150000 1100000 850000 10000000 200000 4650000 800000 5200000 150000 0 850000 9350000 -20037508.342789 -20037508.342789 20037508.342789 20037508.342789 150000 0 850000 9350000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 0 850000 9350000 150000 0 850000 9350000 150000 0 850000 9350000 150000 0 850000 9350000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 0 850000 9350000 350000 0 650000 200000 150000 0 850000 9350000 150000 0 850000 9350000 150000 1100000 850000 10000000 150000 0 850000 9350000 150000 0 850000 9350000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 0 850000 9350000 150000 0 850000 9350000 150000 0 850000 9350000 150000 1100000 850000 10000000 -20037508.342789 -20037508.342789 20037508.342789 20037508.342789 150000 1100000 850000 10000000 150000 0 850000 9350000 150000 0 850000 9350000 150000 1100000 850000 10000000 150000 0 850000 9350000 150000 0 850000 9350000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 0 850000 9350000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 -951600 -1353400 -159500 -911100 150000 0 850000 9350000 150000 1100000 850000 10000000 150000 0 850000 9350000 150000 0 850000 9350000 150000 1100000 850000 10000000 150000 0 850000 9350000 150000 0 850000 9350000 150000 0 850000 9350000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 0 850000 9350000 150000 0 850000 9350000 150000 0 850000 9350000 150000 0 850000 9350000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 0 850000 9350000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 0 850000 9350000 150000 1100000 850000 10000000 150000 0 850000 9350000 150000 0 850000 9350000 150000 0 850000 9350000 150000 0 850000 9350000 150000 0 850000 9350000 350000 0 650000 200000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 0 850000 9350000 150000 0 850000 9350000 150000 0 850000 9350000 150000 0 850000 9350000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 0 850000 9350000 150000 0 850000 9350000 150000 0 850000 9350000 150000 0 850000 9350000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 0 850000 9350000 image/png image/jpeg image/jpg image/tiff application/vnd.google-earth.kmz+xml image/tiff;depth=8 image/tiff;depth=16 image/tiff;depth=32f application/vnd.google-earth.kmz+xml;image_type=image/jpeg application/vnd.google-earth.kmz+xml;image_type=image/png application/x-esri-shape application/json PopularWebMercator512 PopularWebMercator256 GBR FR D48 D96 CZE HR UTM1N UTM1S UTM2N False color (vegetation) False color (vegetation) -180 -90 180 90 FALSE-COLOR time ISO8601 2024-05-14 false 1984-03-01/2024-05-14/P1D 150000 1100000 850000 10000000 150000 0 850000 9350000 150000 0 850000 9350000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 0 850000 9350000 150000 0 850000 9350000 150000 1100000 850000 10000000 -120000 -20000 760000 1280000 150000 0 850000 9350000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 0 850000 9350000 150000 0 850000 9350000 150000 1100000 850000 10000000 150000 0 850000 9350000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 0 850000 9350000 150000 0 850000 9350000 -378306 6005280 1320650 7235613 150000 1100000 850000 10000000 150000 0 850000 9350000 150000 0 850000 9350000 150000 0 850000 9350000 150000 1100000 850000 10000000 150000 0 850000 9350000 150000 0 850000 9350000 150000 1100000 850000 10000000 200000 4650000 800000 5200000 150000 0 850000 9350000 -20037508.342789 -20037508.342789 20037508.342789 20037508.342789 150000 0 850000 9350000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 0 850000 9350000 150000 0 850000 9350000 150000 0 850000 9350000 150000 0 850000 9350000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 0 850000 9350000 350000 0 650000 200000 150000 0 850000 9350000 150000 0 850000 9350000 150000 1100000 850000 10000000 150000 0 850000 9350000 150000 0 850000 9350000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 0 850000 9350000 150000 0 850000 9350000 150000 0 850000 9350000 150000 1100000 850000 10000000 -20037508.342789 -20037508.342789 20037508.342789 20037508.342789 150000 1100000 850000 10000000 150000 0 850000 9350000 150000 0 850000 9350000 150000 1100000 850000 10000000 150000 0 850000 9350000 150000 0 850000 9350000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 0 850000 9350000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 -951600 -1353400 -159500 -911100 150000 0 850000 9350000 150000 1100000 850000 10000000 150000 0 850000 9350000 150000 0 850000 9350000 150000 1100000 850000 10000000 150000 0 850000 9350000 150000 0 850000 9350000 150000 0 850000 9350000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 0 850000 9350000 150000 0 850000 9350000 150000 0 850000 9350000 150000 0 850000 9350000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 0 850000 9350000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 0 850000 9350000 150000 1100000 850000 10000000 150000 0 850000 9350000 150000 0 850000 9350000 150000 0 850000 9350000 150000 0 850000 9350000 150000 0 850000 9350000 350000 0 650000 200000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 0 850000 9350000 150000 0 850000 9350000 150000 0 850000 9350000 150000 0 850000 9350000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 0 850000 9350000 150000 0 850000 9350000 150000 0 850000 9350000 150000 0 850000 9350000 150000 1100000 850000 10000000 150000 1100000 850000 10000000 150000 0 850000 9350000 image/png image/jpeg image/jpg image/tiff application/vnd.google-earth.kmz+xml image/tiff;depth=8 image/tiff;depth=16 image/tiff;depth=32f application/vnd.google-earth.kmz+xml;image_type=image/jpeg application/vnd.google-earth.kmz+xml;image_type=image/png application/x-esri-shape application/json PopularWebMercator512 PopularWebMercator256 GBR FR D48 D96 CZE HR UTM1N UTM1S UTM2N UTM2S PopularWebMercator512 urn:ogc:def:crs:EPSG::3857 1 279541132.014359 -20037508.342789 20037508.342789 512 512 1 1 2 139770566.007179 -20037508.342789 20037508.342789 512 512 2 2 3 69885283.00359 -20037508.342789 20037508.342789 512 512 4 4 4 34942641.501795 -20037508.342789 20037508.342789 512 512 8 8 5 17471320.750897 -20037508.342789 20037508.342789 512 512 16 16 6 8735660.375449 -20037508.342789 20037508.342789 512 512 32 32 7 4367830.187724 -20037508.342789 20037508.342789 512 512 64 64 8 2183915.093862 -20037508.342789 20037508.342789 512 512 128 128 9 1091957.546931 -20037508.342789 20037508.342789 512 512 256 256 10 545978.773466 -20037508.342789 20037508.342789 512 512 512 512 11 272989.386733 -20037508.342789 20037508.342789 512 512 1024 1024 12 136494.693366 -20037508.342789 20037508.342789 512 512 2048 2048 13 68247.346683 -20037508.342789 20037508.342789 512 512 4096 4096 14 34123.673342 -20037508.342789 20037508.342789 512 512 8192 8192 15 17061.836671 -20037508.342789 20037508.342789 512 512 16384 16384 16 8530.918335 -20037508.342789 20037508.342789 512 512 32768 32768 17 4265.459168 -20037508.342789 20037508.342789 512 512 65536 65536 18 2132.729584 -20037508.342789 20037508.342789 512 512 131072 131072 19 1066.364792 -20037508.342789 20037508.342789 512 512 262144 262144 20 533.182396 -20037508.342789 20037508.342789 512 512 524288 524288 PopularWebMercator256 urn:ogc:def:crs:EPSG::3857 urn:ogc:def:wkss:OGC:1.0:GoogleMapsCompatible 0 559082264.028718 -20037508.342789 20037508.342789 256 256 1 1 1 279541132.014359 -20037508.342789 20037508.342789 256 256 2 2 2 139770566.007179 -20037508.342789 20037508.342789 256 256 4 4 3 69885283.00359 -20037508.342789 20037508.342789 256 256 8 8 4 34942641.501795 -20037508.342789 20037508.342789 256 256 16 16 5 17471320.750897 -20037508.342789 20037508.342789 256 256 32 32 6 8735660.375449 -20037508.342789 20037508.342789 256 256 64 64 7 4367830.187724 -20037508.342789 20037508.342789 256 256 128 128 8 2183915.093862 -20037508.342789 20037508.342789 256 256 256 256 9 1091957.546931 -20037508.342789 20037508.342789 256 256 512 512 10 545978.773466 -20037508.342789 20037508.342789 256 256 1024 1024 11 272989.386733 -20037508.342789 20037508.342789 256 256 2048 2048 12 136494.693366 -20037508.342789 20037508.342789 256 256 4096 4096 13 68247.346683 -20037508.342789 20037508.342789 256 256 8192 8192 14 34123.673342 -20037508.342789 20037508.342789 256 256 16384 16384 15 17061.836671 -20037508.342789 20037508.342789 256 256 32768 32768 16 8530.918335 -20037508.342789 20037508.342789 256 256 65536 65536 17 4265.459168 -20037508.342789 20037508.342789 256 256 131072 131072 18 2132.729584 -20037508.342789 20037508.342789 256 256 262144 262144 19 1066.364792 -20037508.342789 20037508.342789 256 256 524288 524288 20 533.182396 -20037508.342789 20037508.342789 256 256 1048576 1048576 GBR urn:ogc:def:crs:EPSG::27700 5 9068080.357143 -120000 1280000 347 512 1 1 6 4534040.178571 -120000 1280000 347 512 2 2 7 2267020.089286 -120000 1280000 463 512 3 4 8 1133510.044643 -120000 1280000 463 512 6 8 9 566755.022321 -120000 1280000 505 512 11 16 10 283377.511161 -120000 1280000 505 512 22 32 11 141688.75558 -120000 1280000 505 512 44 64 12 70844.37779 -120000 1280000 510 512 87 128 13 35422.188895 -120000 1280000 510 512 174 256 14 17711.094448 -120000 1280000 512 512 347 512 15 8855.547224 -120000 1280000 512 512 694 1024 16 4427.773612 -120000 1280000 512 512 1387 2048 17 2213.886806 -120000 1280000 512 512 2773 4096 FR urn:ogc:def:crs:EPSG::2154 5 11850976.5625 -378306 7235613 512 371 1 1 6 5925488.28125 -378306 7235613 512 371 2 2 7 2962744.140625 -378306 7235613 512 495 4 3 8 1481372.070313 -378306 7235613 512 495 8 6 9 740686.035156 -378306 7235613 512 495 16 12 10 370343.017578 -378306 7235613 512 495 32 24 11 185171.508789 -378306 7235613 512 505 64 47 12 92585.754395 -378306 7235613 512 511 128 93 13 46292.877197 -378306 7235613 512 511 256 186 14 23146.438599 -378306 7235613 512 512 512 371 15 11573.219299 -378306 7235613 512 512 1024 742 16 5786.60965 -378306 7235613 512 512 2048 1484 17 2893.304825 -378306 7235613 512 512 4096 2967 D48 urn:ogc:def:crs:EPSG::3912 8 2092633.928571 350000 200000 512 342 1 1 9 1046316.964286 350000 200000 512 342 2 2 10 523158.482143 350000 200000 512 456 4 3 11 261579.241071 350000 200000 512 456 8 6 12 130789.620536 350000 200000 512 497 16 11 13 65394.810268 350000 200000 512 497 32 22 14 32697.405134 350000 200000 512 509 64 43 15 16348.702567 350000 200000 512 509 128 86 16 8174.351283 350000 200000 512 512 256 171 17 4087.175642 350000 200000 512 512 512 342 D96 urn:ogc:def:crs:EPSG::3794 8 2092633.928571 350000 200000 512 342 1 1 9 1046316.964286 350000 200000 512 342 2 2 10 523158.482143 350000 200000 512 456 4 3 11 261579.241071 350000 200000 512 456 8 6 12 130789.620536 350000 200000 512 497 16 11 13 65394.810268 350000 200000 512 497 32 22 14 32697.405134 350000 200000 512 509 64 43 15 16348.702567 350000 200000 512 509 128 86 16 8174.351283 350000 200000 512 512 256 171 17 4087.175642 350000 200000 512 512 512 342 CZE urn:ogc:def:crs:EPSG::5514 6 5525251.116071 -951600 -911100 512 286 1 1 7 2762625.558036 -951600 -911100 512 286 2 2 8 1381312.779018 -951600 -911100 512 382 4 3 9 690656.389509 -951600 -911100 512 458 8 5 10 345328.194754 -951600 -911100 512 509 16 9 11 172664.097377 -951600 -911100 512 509 32 18 12 86332.048689 -951600 -911100 512 509 64 36 13 43166.024344 -951600 -911100 512 509 128 72 14 21583.012172 -951600 -911100 512 512 256 143 15 10791.506086 -951600 -911100 512 512 512 286 16 5395.753043 -951600 -911100 512 512 1024 572 17 2697.876522 -951600 -911100 512 512 2048 1144 HR urn:ogc:def:crs:EPSG::3765 7 4185267.857143 200000 5200000 512 470 1 1 8 2092633.928571 200000 5200000 512 470 2 2 9 1046316.964286 200000 5200000 512 470 4 4 10 523158.482143 200000 5200000 512 470 8 8 11 261579.241071 200000 5200000 512 501 16 15 12 130789.620536 200000 5200000 512 501 32 30 13 65394.810268 200000 5200000 512 510 64 59 14 32697.405134 200000 5200000 512 510 128 118 15 16348.702567 200000 5200000 512 512 256 235 16 8174.351283 200000 5200000 512 512 512 470 17 4087.175642 200000 5200000 512 512 1024 939 UTM1N urn:ogc:def:crs:EPSG::32601 3 65220424.107143 150000 9350000 39 512 1 1 4 32610212.053571 150000 9350000 77 512 1 2 5 16305106.026786 150000 9350000 154 512 1 4 6 8152553.013393 150000 9350000 307 512 1 8 7 4076276.506696 150000 9350000 307 512 2 16 8 2038138.253348 150000 9350000 409 512 3 32 9 1019069.126674 150000 9350000 491 512 5 64 10 509534.563337 150000 9350000 491 512 10 128 11 254767.281669 150000 9350000 491 512 20 256 12 127383.640834 150000 9350000 504 512 39 512 13 63691.820417 150000 9350000 510 512 77 1024 14 31845.910209 150000 9350000 510 512 154 2048 15 15922.955104 150000 9350000 512 512 307 4096 16 7961.477552 150000 9350000 512 512 614 8192 17 3980.738776 150000 9350000 512 512 1227 16384 UTM1S urn:ogc:def:crs:EPSG::32701 3 62081473.214286 150000 10000000 41 512 1 1 4 31040736.607143 150000 10000000 81 512 1 2 5 15520368.303571 150000 10000000 162 512 1 4 6 7760184.151786 150000 10000000 323 512 1 8 7 3880092.075893 150000 10000000 323 512 2 16 8 1940046.037946 150000 10000000 430 512 3 32 9 970023.018973 150000 10000000 430 512 6 64 10 485011.509487 150000 10000000 469 512 11 128 11 242505.754743 150000 10000000 491 512 21 256 12 121252.877372 150000 10000000 503 512 41 512 13 60626.438686 150000 10000000 510 512 81 1024 14 30313.219343 150000 10000000 510 512 162 2048 15 15156.609671 150000 10000000 511 512 323 4096 16 7578.304836 150000 10000000 512 512 645 8192 17 3789.152418 150000 10000000 512 512 1289 16384 UTM2N urn:ogc:def:crs:EPSG::32602 3 65220424.107143 150000 9350000 39 512 1 1 4 32610212.053571 150000 9350000 77 512 1 2 5 16305106.026786 150000 9350000 154 512 1 4 6 8152553.013393 150000 9350000 307 512 1 8 7 4076276.506696 150000 9350000 307 512 2 16 8 2038138.253348 150000 9350000 409 512 3 32 9 1019069.126674 150000 9350000 491 512 5 64 10 509534.563337 150000 9350000 491 512 10 128 11 254767.281669 150000 9350000 491 512 20 256 12 127383.640834 150000 9350000 504 512 39 512 13 63691.820417 150000 9350000 510 512 77 1024 14 31845.910209 150000 9350000 510 512 154 2048 15 15922.955104 150000 9350000 512 512 307 4096 16 7961.477552 150000 9350000 512 512 614 8192 17 3980.738776 150000 9350000 512 512 1227 16384 UTM2S urn:ogc:def:crs:EPSG::32702 3 62081473.214286 150000 10000000 41 512 1 1 4 31040736.607143 150000 10000000 81 512 1 2 5 15520368.303571 150000 10000000 162 512 1 4 6 7760184.151786 150000 10000000 323 512 1 8 7 3880092.075893 150000 10000000 323 512 2 16 8 1940046.037946 150000 10000000 430 512 3 32 9 970023.018973 150000 10000000 430 512 6 64 10 485011.509487 150000 10000000 469 512 11 128 11 242505.754743 150000 10000000 491 512 21 256 12 121252.877372 150000 10000000 503 512 41 512 13 60626.438686 150000 10000000 510 512 81 1024 14 30313.219343 150000 10000000 510 512 162 2048 15 15156.609671 150000 10000000 511 512 323 4096 16 7578.304836 150000 10000000 512 512 645 8192 17 3789.152418 150000 10000000 512 512 1289 16384 ```

Note how each Layer has a list of formats that are supported for that Layer:

      <Format>image/png</Format>
      <Format>image/jpeg</Format>
      <Format>image/jpg</Format>
      <Format>image/tiff</Format>
      <Format>application/vnd.google-earth.kmz+xml</Format>
      <Format>image/tiff;depth=8</Format>
      <Format>image/tiff;depth=16</Format>
      <Format>image/tiff;depth=32f</Format>
      <Format>application/vnd.google-earth.kmz+xml;image_type=image/jpeg</Format>
      <Format>application/vnd.google-earth.kmz+xml;image_type=image/png</Format>
      <Format>application/x-esri-shape</Format>
      <Format>application/json</Format>

You can get a specific tile in a specific format by providing the FORMAT=image/tiff parameter to the GetTile request, like this:

curl -s "https://services.sentinel-hub.com/ogc/wmts/<INSTANCE_ID>?REQUEST=GetTile&BBOX=3238005,5039853,3244050,5045897&RESOLUTION=10&TILEMATRIXSET=PopularWebMercator512&LAYER=FALSE-COLOR&MAXCC=20&TILEMATRIX=14&TILEROW=3065&TILECOL=4758&TIME=2018-03-29/2018-05-29&FORMAT=image/tiff" -o tile.tiff

That command saves a single tile in a file named tile.tiff. You can pick any of the formats from the supported list in the WMTS capabilties document. Again, that works with a KVP service, but for our case of using REST URIs, we'd need to provide format-specific ResourceURL templates for each format.

ianguerin commented 6 months ago

I may have shared a bad example, another tile mentioned in the QGIS logs is https://arcticdata.io/data/10.18739/A2KW57K57/iwp_geotiff_high/WGS1984Quad/2/0/0.tif which I can load as an independent Raster in QGIS, but doesn't work when trying to load the WMTS layer.

Here's the slimmed down GetCapabilities response I've been working with:

```xml PDG Ice-wedge polygon high OGC WMTS 1.0.0 RESTful RESTful iwp_high iwp_high -179.91531896747117 50.16996707215903 179.91531896747247 80.0978646943821 image/tiff image/png WGS1984Quad CRS84 for the World WGS1984Quad -180 -90 180 90 http://www.opengis.net/def/crs/OGC/1.3/CRS84 http://www.opengis.net/def/wkss/OGC/1.0/GoogleCRS84Quad 0 279541132.0143589 -180 90 256 256 2 1 1 139770566.0071794 -180 90 256 256 4 2 2 69885283.00358972 -180 90 256 256 8 4 3 34942641.50179486 -180 90 256 256 16 8 4 17471320.75089743 -180 90 256 256 32 16 5 8735660.375448715 -180 90 256 256 64 32 6 4367830.187724357 -180 90 256 256 128 64 7 2183915.093862179 -180 90 256 256 256 128 8 1091957.546931089 -180 90 256 256 512 256 9 545978.7734655447 -180 90 256 256 1024 512 10 272989.3867327723 -180 90 256 256 2048 1024 11 136494.6933663862 -180 90 256 256 4096 2048 12 68247.34668319309 -180 90 256 256 8192 4096 13 34123.67334159654 -180 90 256 256 16384 8192 14 17061.83667079827 -180 90 256 256 32768 16384 15 8530.918335399136 -180 90 256 256 65536 32768 ```

Where file:///home/path/to/file is the actual filepath

ianguerin commented 6 months ago

After much trial and error, I think @yvonnesjy and I have figured out the issue. It seems that GeoTIFFS that has an interleave metadata option of "BAND" are not rendering properly through WMTS in QGIS, but interleave metadata option of "PIXEL" is working fine when loaded as WMS/WMTS.

Here's a link to GDAL docs about creation options. Notably:

... but some applications only support pixel interleaved TIFF files.

I was able to convert a band-interleaved file to pixel-interleaved and QGIS displayed it when loaded as WMS/WMTS. I think the next step is to run our viz pipeline on a subset of one of our datasets (Ice-wedge polygons is what I've been looking at) and change the GeoTIFF creation to override the default interleave creation option (which is band by default).

yvonnesjy commented 6 months ago

Today's update:

Interleave turned out to be a correlation, not a cause. By updating the band data type to int32 (instead of float64) (thanks to @ianguerin !), QGIS downloads the tifs successfully. Yesterday when we exported the file as pixel interleaved, it changed the data type to byte, which turned out to also be supported.

This thread suggests there are limitations to the data types WMTS can support. Both that and its linked thread suggest WCS is the way to go. The description of "an open specification for sharing raster datasets on the web" does fit our use case.

@mbjones Is WCS actually what we want, rather than WMTS?

@ianguerin also posted a question to continue exploring the WMTS path.

mbjones commented 6 months ago

WCS may be the way to go, but I haven't looked at it in years. It is from the older family of OGC specifications, and would likely require a dedicated WCS server IIRC (whereas WMTS can be served from any web location, no special server needed) -- but we'd need to explore that further.

mbjones commented 6 months ago

Reading the threads you linked, I see they are talking about WMS and not about WMTS -- WMS is the older family spec as well, and we've not been using it.

mbjones commented 6 months ago

One last comment (sorry for the stream)... WMTS enables serving arbitrary formats, and uses different identifiers for different types. For example, here's the list from SentinelHub for the example I posted the other day:

      <Format>image/png</Format>
      <Format>image/jpeg</Format>
      <Format>image/jpg</Format>
      <Format>image/tiff</Format>
      <Format>application/vnd.google-earth.kmz+xml</Format>
      <Format>image/tiff;depth=8</Format>
      <Format>image/tiff;depth=16</Format>
      <Format>image/tiff;depth=32f</Format>
      <Format>application/vnd.google-earth.kmz+xml;image_type=image/jpeg</Format>
      <Format>application/vnd.google-earth.kmz+xml;image_type=image/png</Format>
      <Format>application/x-esri-shape</Format>
      <Format>application/json</Format>

Notice that the tiff formats include a depth parameter. Have you tried setting that to match our file format?

ianguerin commented 6 months ago

Is there a way to determine what "depth" our GeoTIFFs are? I tried various values, mostly anytime I added ;depth=X to the Format string I started seeing 301 HTTP errors in the network tab in QGIS.

mbjones commented 6 months ago

The GDAL GTiff driver (https://gdal.org/drivers/raster/gtiff.html) is the defacto format definition as it is used under the hood for most geo tools, including QGIS it seems. That documentation says:

Currently band types of Byte, UInt16, Int16, UInt32, Int32, Float32, Float64, CInt16, CInt32, CFloat32 and CFloat64 are supported for reading and writing

How that maps to the depth string in WMTS is unknown to me, but I'll bet depth=16 corresponds to a GTiff drive pixel data type of Int16, and depth=32f corresponds to Float32. QGIS should be able to open any file that was created with the GDAL GTiff driver.

Each band in the raster can have its own data type, and gdalinfo will report the actual datatype of each band -- see this example showing a band with type Byte: https://gdal.org/programs/gdalinfo.html#example I'm not sure how those map onto the Format string options in WMTS. Hope some of this is useful to you.

ianguerin commented 6 months ago

That was my assumption as well. No luck using the depth parameter, though. QGIS has no problem opening the GeoTIFF; to be clear it is just when I try to load it via WMTS. I'll keep exploring though. The response I got on my stackexchange question seems to think that GeoTIFFs are not the primary use case for WMTS. Quote: "It is recommended that servers offer Tiles in the image/png and image/jpeg file formats"

yvonnesjy commented 6 months ago

Some thoughts and findings:

image (1)

robyngit commented 3 weeks ago

Document summarizing some experiments with this: https://docs.google.com/document/d/1pVGlacPihHXCqO9451bVh68VeIyHC5erPx2g0RD2UQY/edit?tab=t.0