qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.32k stars 2.97k forks source link

Give support to an OGC API Tiles layer #50296

Open doublebyte1 opened 1 year ago

doublebyte1 commented 1 year ago

Feature description

With the publication of part 1 of OGC API - Tiles, it would be great if QGIS would support adding layers published using this standard.

The idea would be to allow users to use the browser panel or the layer menu, to connect to a conformant server, and pull OGC API Tiles layers. OGC API Tiles supports vector, map and coverage tiles, but I think that it would be easier to start with vector tiles.

Additional context

If the community thinks this useful, I could start working on a PR.

jerstlouis commented 1 year ago

@doublebyte1 This was already working when we tested in 2021 during the Modular OGC API Workflows project using the GDAL OGC API driver which is available in GDAL 3.2+. Maps, Coverages, Tiles (including Map tiles, Coverages tiles, Vector tiles) were all working well. (NOTE: Even though the ogcapi GDAL driver is classified as raster, it also supports vector tiles. There is a comment saying that it could perhaps eventually also be merged with the oapif OGC API - Features driver).

From the menu bar, you select Layer > Add Layer > Vector (for vector tiles) or Raster (for Maps / Coverage (Tiles)) ; keep File radio button selected, and for Vector dataset prefix the URL to either the landing page or an individual collection by OGCAPI:. This process should probably be made more intuitive / obvious and better documented.

Then you can select a preferred API, format, TileMatrixSet as per the opening options of the OGC API driver.

See (draft) demo video at https://www.dailymotion.com/video/x80xzex (password: ModularWorkflows) at ~18:30 timestamp.

It would be nice to experiment with this again at the Web Mapping Code sprint next week to make sure it still works as expected.

EDIT: Just tested, and this still works: OGCAPI:https://maps.gnosis.earth/ogcapi/collections/blueMarble Not as much luck with OGCAPI:https://maps.gnosis.earth/ogcapi/collections/Daraa:AgricultureSrf ...

tomkralidis commented 1 year ago

Given the above, we should also consider overall OGC API workflow in QGIS (Layer -> Add OGC API Layer?).

doublebyte1 commented 1 year ago

I think that is a great idea. We could add a collection endpoint, and QGIS would give the option to render it in whichever OAPIs are available (pretty much what is implemented now).

@tomkralidis but maybe OGC API Records should stay out of this? What do you think?

doublebyte1 commented 1 year ago

@doublebyte1 This was already working when we tested in 2021 during the Modular OGC API Workflows project using the GDAL OGC API driver which is available in GDAL 3.2+. Maps, Coverages, Tiles (including Map tiles, Coverages tiles, Vector tiles) were all working well. (NOTE: Even though the ogcapi GDAL driver is classified as raster, it also supports vector tiles. There is a comment saying that it could perhaps eventually also be merged with the oapif OGC API - Features driver).

From the menu bar, you select Layer > Add Layer > Vector (for vector tiles) or Raster (for Maps / Coverage (Tiles)) ; keep File radio button selected, and for Vector dataset prefix the URL to either the landing page or an individual collection by OGCAPI:. This process should probably be made more intuitive / obvious and better documented.

Then you can select a preferred API, format, TileMatrixSet as per the opening options of the OGC API driver.

See (draft) demo video at https://www.dailymotion.com/video/x80xzex (password: ModularWorkflows) at ~18:30 timestamp.

It would be nice to experiment with this again at the Web Mapping Code sprint next week to make sure it still works as expected.

EDIT: Just tested, and this still works: OGCAPI:https://maps.gnosis.earth/ogcapi/collections/blueMarble Not as much luck with OGCAPI:https://maps.gnosis.earth/ogcapi/collections/Daraa:AgricultureSrf ...

@jerstlouis I suppose this is the matching (not 100% clear from the documentation of the driver):

jerstlouis commented 1 year ago

@doublebyte1 Yes, correct, that is the mapping of the resources / access mechanisms to the OGC API Standards.

As you say, Tiles is not only for Vector Tiles, but also for Coverage Tiles and Map Tiles.

Note that one of the first things that should be fixed is this issue about supporting 2DTMS 2.0 in GDAL:

https://github.com/OSGeo/gdal/issues/6882

which really should not be too difficult, so a good thing to tackle at this upcoming code sprint. Happy to provide additional 2DTMS guidance to anyone working on this.

doublebyte1 commented 1 year ago

@jerstlouis that sounds good. I have tested it and it works for:

doublebyte1 commented 1 year ago

I created a new issue here: https://github.com/qgis/QGIS/issues/52674

jerstlouis commented 1 year ago

@doublebyte1 I just tested and OGC API - Maps does work here on my end in QGIS 3.28.3-Firenze with our end-points.

If you select Layer menu, Add Raster Layer, leave File radio button selected, then OGCAPI:https://maps.gnosis.earth/ogcapi/collections/blueMarble and select MAP as the API and JPEG as the image format.

qgis-OGCAPIMaps

Make sure your GDAL is 3.6 or later and includes this fix:

https://github.com/OSGeo/gdal/commit/761f66c8baa5f426c269fb30b3839f1a7f3a3fc5

for

https://github.com/OSGeo/gdal/issues/6832

doublebyte1 commented 1 year ago

I have GDAL 3.6.2, released 2023/01/02 but it does not work.


Unsupported Data Source: OGCAPI:https://maps.gnosis.earth/ogcapi/collections/blueMarble|option:API=MAP|option:IMAGE_FORMAT=JPEG is not a supported raster data source API MAP requested, but not available```
agiudiceandrea commented 1 year ago

@doublebyte1 I can confirm that it works using either QGIS 3.28.4 with GDAL 3.6.2 or QGIS 3.28.5 with GDAL 3.6.3.

doublebyte1 commented 1 year ago

@agiudiceandrea Thank You! It seems to be a problem with the mac os package, which uses an older version of GDAL.

doublebyte1 commented 1 year ago

@jerstlouis I have submitted this to address some issues: https://github.com/OSGeo/gdal/pull/7656 I'll have a look at https://github.com/OSGeo/gdal/issues/6882, once this is merged.

doublebyte1 commented 1 year ago

@doublebyte1 This was already working when we tested in 2021 during the Modular OGC API Workflows project using the GDAL OGC API driver which is available in GDAL 3.2+. Maps, Coverages, Tiles (including Map tiles, Coverages tiles, Vector tiles) were all working well. (NOTE: Even though the ogcapi GDAL driver is classified as raster, it also supports vector tiles. There is a comment saying that it could perhaps eventually also be merged with the oapif OGC API - Features driver).

From the menu bar, you select Layer > Add Layer > Vector (for vector tiles) or Raster (for Maps / Coverage (Tiles)) ; keep File radio button selected, and for Vector dataset prefix the URL to either the landing page or an individual collection by OGCAPI:. This process should probably be made more intuitive / obvious and better documented.

Then you can select a preferred API, format, TileMatrixSet as per the opening options of the OGC API driver.

See (draft) demo video at https://www.dailymotion.com/video/x80xzex (password: ModularWorkflows) at ~18:30 timestamp.

It would be nice to experiment with this again at the Web Mapping Code sprint next week to make sure it still works as expected.

EDIT: Just tested, and this still works: OGCAPI:https://maps.gnosis.earth/ogcapi/collections/blueMarble Not as much luck with OGCAPI:https://maps.gnosis.earth/ogcapi/collections/Daraa:AgricultureSrf ...

This seems to be raster tiles, only? OGCAPI:https://maps.gnosis.earth/ogcapi/collections/blueMarble. For testing vector tiles I used this: OGCAPI:https://maps.gnosis.earth/ogcapi/collections/Daraa

agiudiceandrea commented 1 year ago

Thank You! It seems to be a problem with the mac os package, which uses an older version of GDAL.

@doublebyte1, so, was your previous comment:

I have GDAL 3.6.2, released 2023/01/02 but it does not work. Unsupported Data Source: >OGCAPI:https://maps.gnosis.earth/ogcapi/collections/blueMarble|option:API=MAP|option:IMAGE_FORMAT=JPEG is not a supported raster data source API MAP requested, but not available

incorrect about the GDAL version used?

jerstlouis commented 1 year ago

@doublebyte1 blueMarble provides raster tiles only (and the reason it was working when I tested that time was because it was using OGC API - Coverages).

OGCAPI:https://maps.gnosis.earth/ogcapi/collections/Daraa:AgricultureSrf provides vector tiles for a single layer, whereas OGCAPI:https://maps.gnosis.earth/ogcapi/collections/Daraa provides multi-layer vector tiles, including the Agricultural Surfaces layer (both options should work).

doublebyte1 commented 1 year ago

Thank You! It seems to be a problem with the mac os package, which uses an older version of GDAL.

@doublebyte1, so, was your previous comment:

I have GDAL 3.6.2, released 2023/01/02 but it does not work. Unsupported Data Source: >OGCAPI:https://maps.gnosis.earth/ogcapi/collections/blueMarble|option:API=MAP|option:IMAGE_FORMAT=JPEG is not a supported raster data source API MAP requested, but not available

incorrect about the GDAL version used?

@agiudiceandrea On my system, I am running gdal 3.62. I am running the current version of QGIS 3.30.

In linux, using the master version of QGIS and the master version of gdal (both compiled from source), everything works as expected.

doublebyte1 commented 1 year ago

@doublebyte1 blueMarble provides raster tiles only (and the reason it was working when I tested that time was because it was using OGC API - Coverages).

OGCAPI:https://maps.gnosis.earth/ogcapi/collections/Daraa:AgricultureSrf provides vector tiles for a single layer, whereas OGCAPI:https://maps.gnosis.earth/ogcapi/collections/Daraa provides multi-layer vector tiles, including the Agricultural Surfaces layer (both options should work).

@jerstlouis With the fix I was able to load raster tiles in QGIS, but not vector tiles. Maybe because of the issue you described here: https://github.com/OSGeo/gdal/pull/7656/files/955d044b188ee338f923000a3bf161530cecb7a7#r1181229171

Screenshot from 2023-04-30 14-51-33

doublebyte1 commented 1 year ago

With this https://github.com/OSGeo/gdal/pull/7656 , we can read OGC API (raster) tiles in QGIS, at least from WorldCRS84Quad. I will close this issue for now.

doublebyte1 commented 9 months ago

This appears to have stopped working again:

Screenshot 2023-12-11 at 20 18 21
2023-12-11T20:18:44     CRITICAL    Unsupported Data Source : OGCAPI:https://maps.gnosis.earth/ogcapi/collections/blueMarble/tiles|option:API=TILES|option:TILEMATRIXSET=WorldCRS84Quad is not a supported raster data source
             Missing bbox
jerstlouis commented 9 months ago

@doublebyte1 The supported end-point for GDAL / QGIS are either the landing page (ending here at /ogcapi) or the collection (ending at /blueMarble)

Does it work if you remove the /tiles part? (which is the list of map tilesets).

(unless new support for tileset lists end-points was added more recently to GDAL and I am not aware of it).

doublebyte1 commented 9 months ago

@doublebyte1 The supported end-point for GDAL / QGIS are either the landing page (ending here at /ogcapi) or the collection (ending at /blueMarble)

Does it work if you remove the /tiles part? (which is the list of map tilesets).

(unless new support for tileset lists end-points was added more recently to GDAL and I am not aware of it).

No, it doesn't.

Unsupported Data Source : OGCAPI:https://maps.gnosis.earth/ogcapi/collections/blueMarble|option:API=TILES|option:TILEMATRIXSET=WorldCRS84Quad is not a supported raster data source
             API TILES requested, but not available
doublebyte1 commented 9 months ago

When opening the landing page, it does detect the layers, but then it does not manage to open any.

Screenshot 2023-12-12 at 10 06 41
kudlav commented 2 months ago

Hi, I'm testing the compatibility of QGIS with OGC API Tiles to access tiled data and I'm not very successful.

Loading by tileset description

not supported

Examples are from OpenLayers: raster, vector.

Loading from the landing page

Loading from the collection description

{
  "dataType": "map",
  "crs": "http://www.opengis.net/def/crs/EPSG/0/4326",
  "extent": {
    "spatial": {
      "bbox": [[-180, -90, 180, 90]]
    }
  },
  "links": [
    {
      "rel": "self",
      "type": "application/json",
      "href": "https://maps.gnosis.earth/ogcapi/collections/blueMarble?f=json"
    },
    {
      "rel": "http://www.opengis.net/def/rel/ogc/1.0/coverage",
      "type": "image/tiff; application=geotiff",
      "href": "https://maps.gnosis.earth/ogcapi/collections/blueMarble/coverage?f=tif"
    },
    {
      "rel": "http://www.opengis.net/def/rel/ogc/1.0/coverage-rangetype",
      "type": "application/json",
      "href": "https://maps.gnosis.earth/ogcapi/collections/blueMarble/coverage/rangetype?f=json"
    }
  ]
}

QGIS 3.38.0 Windows 11

doublebyte1 commented 1 month ago

Status of the Add Layer (Raster and Vector) OGCAPI option using 3.39.0-Master 399f7df1c7 and GDAL3.10.0 dev-126a88523a:

doublebyte1 commented 1 month ago

Details to Reproduce the results on the previous comment

Please note that in order for GDAL to be able to resolve the relative links on the GNOSIS server the version should be >= https://github.com/OSGeo/gdal/commit/b2899289180f6d5bdb1e8ef1566dd0283d1cad90

OGC API - Maps

Screenshot from 2024-07-18 20-43-17

OGC API - Tiles (raster)

Screenshot from 2024-07-18 20-43-52

OGC API - Coverages

Screenshot from 2024-07-18 20-46-48 COVERAGES.

OGC API - Features

More details on this issue.

OGC API - Tiles (vector)

More details on this issue.

kudlav commented 1 month ago

Support of OGC API - Tiles (raster) is only partial as QGIS cannot load tileset from tileset description.

jerstlouis commented 1 month ago

@kudlav I don't think GDAL supports pointing it directly to a tileset end-point yet (e.g., https://maps.gnosis.earth/ogcapi/collections/Daraa/map/tiles/WebMercatorQuad). Perhaps we need to file an issue (feature request -- it's not a bug) for GDAL about this first?

An implementation can actually conform to OGC API - Tiles "Core" without even providing tileset metadata.

If we really want to be comprehensive, it should also be possible to open a tileset by providing a template using variables for level, row, column (e.g., https://maps.gnosis.earth/ogcapi/collections/Daraa/map/tiles/WebMercatorQuad/{tileMatrix}/{tileRow}/{tileCol} plus the URI of a registered 2DTMS (e.g., https://www.opengis.net/def/tilematrixset/OGC/1.0/WebMercatorQuad) or a link or local 2DTMS 2.0 JSON definition (e.g., same link which can also return a JSON definition if following re-direction and using Accept: application/json request header, or somewhere else like https://raw.githubusercontent.com/opengeospatial/2D-Tile-Matrix-Set/master/registry/json/WebMercatorQuad.json).