Comments (7)
Please consider that pystac strongly relies on the presence of "child" links: it is thus mainly for "static catalogs".
The swisstopo implementation is based on the STAC API (which is a superset of the OGC API Features) and not on static catalogs. This means that "child" links are not mandatory and reference to "child collections" is guaranteed by the /collections endpoint, whose "rel" is "data".
The swisstopo implementation is a valid STAC implementation: it is, e.g., indexed and works nicely under STAC Index: https://stacindex.org/catalogs/datageoadminch#/
from python-stac-api.
I'm still in the process of learning about the STAC API, but here is my take on this issue.
It seems to me that the swisstopo STAC API (link) doesn't quite follow the usual practice of organising and linking the STAC objects (or at least in a way that pystac
expects it).
Starting with the "landing page" - https://data.geo.admin.ch/api/stac/v0.9/ - you get a JSON object that more or less corresponds to the STAC Catalog and can be read with pystac
:
from pystac import Catalog
cat = Catalog.from_file('https://data.geo.admin.ch/api/stac/v0.9/')
However, the relation-types of the linked objects don't specify any child objects:
cat.to_dict()
{'id': 'ch',
'stac_version': '0.9.0',
'description': 'Data Catalog of the Swiss Federal Spatial Data Infrastructure',
'links': [{'rel': 'root',
'href': 'https://data.geo.admin.ch/api/stac/v0.9/',
'type': 'application/json'},
{'rel': 'self',
'href': 'https://data.geo.admin.ch/api/stac/v0.9/',
'type': 'application/json',
'title': 'This document'},
{'rel': 'service-doc',
'href': 'https://data.geo.admin.ch/api/stac/static/spec/v0.9/api.html',
'type': 'text/html',
'title': 'The API documentation'},
{'rel': 'service-desc',
'href': 'https://data.geo.admin.ch/api/stac/static/spec/v0.9/openapi.yaml',
'type': 'application/vnd.oai.openapi+yaml;version=3.0',
'title': 'The OPENAPI description of the service'},
{'rel': 'conformance',
'href': 'https://data.geo.admin.ch/api/stac/v0.9/conformance',
'type': 'application/json',
'title': 'OGC API conformance classes implemented by this server'},
{'rel': 'data',
'href': 'https://data.geo.admin.ch/api/stac/v0.9/collections',
'type': 'application/json',
'title': 'Information about the feature collections'},
{'rel': 'search',
'href': 'https://data.geo.admin.ch/api/stac/v0.9/search',
'type': 'application/json',
'title': 'Search across feature collections',
'method': 'GET'},
{'rel': 'search',
'href': 'https://data.geo.admin.ch/api/stac/v0.9/search',
'type': 'application/json',
'title': 'Search across feature collections',
'method': 'POST'}],
'title': 'data.geo.admin.ch'}
Hence, it is not amenable to discovery via the pystac
's walk()
or the get_children()
methods:
list(cat.get_children())
[]
Looking at the link objects of the cat
above, the one with the "data" relation (what should ideally be a "child" relation pointing to sub-catalog / collection) links to https://data.geo.admin.ch/api/stac/v0.9/collections which is a JSON list of STAC collections but itself not a valid STAC object:
next(cat.get_stac_objects(rel="data")) # KeyError: 'id'
You can read-in individual collections (supplying the correct URLs):
from pystac import STAC_IO
col = STAC_IO.read_stac_object("https://data.geo.admin.ch/api/stac/v0.9/collections/ch.swisstopo.landeskarte-farbe-10")
print(type(col)) # pystac.collection.Collection
However, the same issues related to the linking / naming the relation-types persist - so none of col.get_items()
or col.get_children()
actually works.
I don't know if this an issue of STAC spec version being 0.9.0 (I can't imagine the spec would be that much different) or if really the problem is implementation (swisstopo) versus expectation (pystac
).
Maybe @martinchristen knows somebody at swisstopo who could elaborate on this?
from python-stac-api.
Thanks @MatusGasparik this is what I noticed too.
Another "issue" is that you can't convert the output directly to a Python dictionary.
I don't remember which one, but at least one STAC Python Module did the conversion directly using eval (instead of using the json module) and with the swisstopo STAC this conversion doesn't work.
While I really don't recommend using eval to convert JSON to a Python dict, this seems to work for other STAC servers...
from python-stac-api.
I also tried https://github.com/brazil-data-cube/stac.py and another one I don't remember at the moment and they all didn't work.
We could do some bug reports/issues there.
from python-stac-api.
IMHO all these STAC tools do not yet support reading collections information from the /collections endpoint (rel='data')
from python-stac-api.
Both https://github.com/stac-utils/pystac-client and https://github.com/brazil-data-cube/stac.py will soon support reading collections from the /collection endpoint (rel='data'). See:
from python-stac-api.
That is great news, thanks. I will create some examples in this repo here.
from python-stac-api.
Related Issues (1)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-stac-api.