Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STAC client in QGIS core #300

Open
uclaros opened this issue Aug 1, 2024 · 2 comments
Open

STAC client in QGIS core #300

uclaros opened this issue Aug 1, 2024 · 2 comments

Comments

@uclaros
Copy link

uclaros commented Aug 1, 2024

QGIS Enhancement: STAC client in QGIS core

Date 2024/08/01

Author Stefanos Natsis (@uclaros)

Contact stefanos.natsis at lutraconsulting dot co dot uk

Version QGIS 3.40

Summary

This Enhancement Proposal is about bringing support for interacting with STAC catalogs in QGIS.
Currently one can search for data within a STAC catalog in QGIS using the STAC browser plugin, however it is not very practical for browsing the catalog's contents as well as dealing with nested catalogs/collections.
It's time to have STAC catalogs in QGIS core!

Proposed Solution

Code additions

STAC element classes

Basic container classes will be created for STAC objects:

class QgsStacObject
{
}

class QgsStacItem : QgsStacObject
{
}

class QgsStacCatalog : QgsStacObject
{
}

class QgsStacCollection : QgsStacCatalog
{
}

STAC controller

A QgsStacController class will be handling the network requests and JSON parsing.
The controller will function as a factory, generating reply objects, which will fire a signal once the network reply is received. The appropriate QgsStacObject will then be returned by the reply object based on the received STAC object type.

class QgsStacController : QObject
{
public:
	QgsStacObjectReply *fetch( QUrl );
	QgsStacSearchReply *search( QUrl );
}


class QgsStacObjectReply : QObject
{
public:
	QgsStacObject::Type type();
	QgsStacItem item();
	QgsStacCollection collection();
	QgsStacCatalog catalog();

signals:
	void finished();

private:
	QNetworkReply *mReply = nullptr;
	std::unique_ptr<QgsStacObject> mStacObject;
}


class QgsStackSearchReply : QObject
{
public:
	QgsStacObject::Type type();
	QVector<QgsStacItem> items();
	QVector<QgsStacCollection> collections();
	QUrl nextPage();

signals:
	void finished();

private:
	QNetworkReply *mReply = nullptr;
	std::unique_ptr<QgsStacObject> mStacObject;
}

QGIS Browser related classes

The necessary classes related to the QGIS Browser will be created:

class QgsStacDataItemProvider : public QgsDataItemProvider
{
}

class QgsStacRootItem : public QgsConnectionsRootItem
{
}

class QgsStacCollectionItem : public QgsDataCollectionItem
{
}

class QgsStacCatalogItem : public QgsDataCollectionItem
{
}

class QgsStacItemItem : public QgsDataCollectionItem
{
}

class QgsStacAssetItem : public QgsDataItem
{
}

class QgsStacDataItemGuiProvider : public QObject, public QgsDataItemGuiProvider
{
	Q_OBJECT

  public:

	QgsStacDataItemGuiProvider() = default;

	QString name() override;
	void populateContextMenu( QgsDataItem *item, QMenu *menu,
                          	const QList<QgsDataItem *> &selectedItems, QgsDataItemGuiContext context ) override;
	bool handleDoubleClick( QgsDataItem *item, QgsDataItemGuiContext context ) override;
}

User facing additions

QGIS Browser Panel

A new STAC node will be added to the browser panel, where the users will be able to add connections to file based or network based STAC catalogs. The catalog's contents (sub Catalogs/Collections/Items/Assets) will be used to populate the tree structure while data will be lazily fetched when nodes are expanded.
Assets with a cloud optimized media type like COG or COPC will be added as remote layers by drag and drop.

image

A right click context menu will be added for further interaction with the STAC elements, allowing downloading of assets, displaying the selected element's properties and showing items' footprints on the map canvas.
On servers that support the STAC API Item search, collection nodes will also include a Search Items... entry on the context menu that will open and pre-populate the STAC Search Panel.
On servers that support the Collection Search STAC API extension, the root node will also include a Search Collections... entry on the context menu that will open and pre-populate the STAC Search Panel.

Data Source Manager

A new STAC tab will be added to the Data Source Manager which will allow managing STAC catalog connections, similar to other connection based data providers.
A combination view will allow browsing, collection searching and item searching on the active catalog on separate tabs:

  • Browse

  • Search Collections

    image

    • Filter parameters may be set on a separate dialog to allow room for more STAC extension widgets to be added. This will probably be decided when building the GUI part and testing its usability.

    image

  • Search Items

    • Users will be able to perform STAC API Item search queries, as well as displaying paginated query results.
    • Selecting items in the results list should highlight their footprints on the main canvas using some ephemeral QgsMapCanvasItem for easy orientation.

    image

    • Filter parameters will be added in a similar way as with Collection search above.

    image

Stac Object Properties

A new Properties dialog will be added which will display the JSON contents of a STAC Catalog, Collection or Item in a human readable way.
Preview assets will be used to generate thumbnails and urls will be rendered as anchors, ideally allowing some navigation between objects (eg going from catalog, to collection, to item and back to root catalog).

image

Risks

The risk of having the STAC specification grow out of control leaving high maintenance needs to the QGIS implementation code is relatively low.
The spec is stable atm and is designed to be expanded through the use of extensions, special handling of which may be added in QGIS core in the future.

Performance Implications

None, users may be more productive when using STAC catalogs though!

Further Considerations/Improvements

Support for further STAC extensions may be added in the future

@02JanDal
Copy link

02JanDal commented Aug 1, 2024

This would be really great!

I have had a similar idea previously, some things I've considered that I think would make sense (don't necessarily need to be added as part of this, but at least should be kept in mind so as not to make it unnecessarily hard to implement later):

  1. Support other cataloging APIs (such as non-STAC OGC API Records, CSW, etc.) using the same UI
  2. Browse a collection "on the map" - dragging a collection (or even the entire service, in case of Collection Search) to the map (or adding it through other means) shows the geometries (if present) of the items on the map, Identify-clicking shows their properties as well as actions for adding assets etc.
    a. Additionally, for collections following appropriate extensions (e.g. https://github.com/stac-extensions/pointcloud) assets with cloud optimized formats (COG, COPC, etc.) would be rendered when sufficiently zoomed in (similar to VPCs)
    b. Additionally, integrate these collection-preview-layers with the temporal controller in QGIS (to allow filtering of the items based on their temporal properties
  3. When adding an OGC API Features layer using the usual means, detect if it actually is a STAC endpoint, and if so ask if the user would rather add it as a STAC endpoint per this proposal

Though possibly just as much work or more than the current proposal by itself, I think the second point is what would really make STAC nice to use in QGIS. After all, it's geographic data so we'd like to browse it on a map, in the context of our existing data, right?

@robbibt
Copy link

robbibt commented Oct 2, 2024

Hey @uclaros, this sounds absolutely brilliant! At Digital Earth Australia we maintain a large STAC catalogue and STAC search API for Australia's national satellite data archive - we'd be very happy to test any prototype out and provide feedback if it would be useful for you!
https://explorer.dea.ga.gov.au/stac
https://knowledge.dea.ga.gov.au/guides/setup/gis/stac.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants