STAC.jl
STAC.jl copied to clipboard
Constructing a STAC.Catalog from a collection url gives a broken catalog without the item information
When I am loading a STAC.Catalog from a collection url I get the assets and the metadata but not the information on the items. When I am opening the parent catalog and select the subcatalog it works.
julia> fnfurl = "https://geoservice.dlr.de/eoc/ogc/stac/v1/"
"https://geoservice.dlr.de/eoc/ogc/stac/v1/"
julia> fnfcat = STAC.Catalog(fnfurl);
julia> fnf = fnfcat["TDM_FNF_50"];
julia> fnfurlcol = "https://geoservice.dlr.de/eoc/ogc/stac/v1/collections/TDM_FNF_50"
"https://geoservice.dlr.de/eoc/ogc/stac/v1/collections/TDM_FNF_50"
julia> fnfcol = STAC.Catalog(fnfurlcol)
TDM_FNF_50
TanDEM-X Forest/Non-Forest Map - Global
The TanDEM-X Forest/Non-Forest Map is a project developed by the Microwaves and Radar Institute at the German Aerospace Center (DLR), within the activities of the TanDEM-X mission. The goal is the derivation of a global forest/non-forest classification mosaic from TanDEM-X bistatic interferometric synthetic aperture radar (InSAR) data, acquired for the generation of the global digital elevation model (DEM) in Stripmap single polarization (HH) mode.
License: proprietary
Assets:
* thumbnail: Thumbnail
* overview: Overview
* metadata: Metadata (ISO19139)
julia> for (id, item) in fnf.items
@show id
end
id = "TDM_FNF_20_N00E006"
id = "TDM_FNF_20_N00E007"
id = "TDM_FNF_20_N00E008"
...
id = "TDM_FNF_20_N00W064"
id = "TDM_FNF_20_N00W065"
julia> for (id, item) in fnfcol.items
@show item
end
I tried to instantiate a catalog object in pystack but I got the following error:
import pystac
cat = pystac.Catalog.from_file("https://geoservice.dlr.de/eoc/ogc/stac/v1/") # ok
cat2 = pystac.Catalog.from_file("https://geoservice.dlr.de/eoc/ogc/stac/v1/collections/TDM_FNF_50")
list(cat2.get_items())
---------------------------------------------------------------------------
STACTypeError Traceback (most recent call last)
Cell In[7], line 5
1 import pystac
2 cat = pystac.Catalog.from_file("https://geoservice.dlr.de/eoc/ogc/stac/v1/") # ok
----> 5 cat2 = pystac.Catalog.from_file("https://geoservice.dlr.de/eoc/ogc/stac/v1/collections/TDM_FNF_50")
7 list(cat2.get_items())
File ~/.local/lib/python3.12/site-packages/pystac/catalog.py:1283, in Catalog.from_file(cls, href, stac_io)
1280 if stac_io is None:
1281 stac_io = pystac.StacIO.default()
-> 1283 result = super().from_file(href, stac_io)
1284 result._stac_io = stac_io
1286 return result
File ~/.local/lib/python3.12/site-packages/pystac/stac_object.py:633, in STACObject.from_file(cls, href, stac_io)
630 href = make_absolute_href(href)
632 d = stac_io.read_json(href)
--> 633 o = cls.from_dict(d, href=href, migrate=True, preserve_dict=False)
635 # If this is a root catalog, set the root to the catalog instance.
636 root_link = o.get_root_link()
File ~/.local/lib/python3.12/site-packages/pystac/catalog.py:1235, in Catalog.from_dict(cls, d, href, root, migrate, preserve_dict)
1232 d = migrate_to_latest(d, info)
1234 if not cls.matches_object_type(d):
-> 1235 raise STACTypeError(d, cls)
1237 catalog_type = CatalogType.determine_type(d)
1239 if preserve_dict:
STACTypeError: JSON (id = TDM_FNF_50) does not represent a Catalog instance.
In [8]: pystac.__version__
Out[8]: '1.12.2'
Indeed, "type" is "Collection" for this url. See also https://github.com/JuliaClimate/STAC.jl/issues/22#issuecomment-3075521866 .