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

Client.get_collection() doesn't work with GeoServer OSEO STAC API #745

Closed
EetuHuuskoCSC opened this issue Oct 22, 2024 · 1 comment · Fixed by #746
Closed

Client.get_collection() doesn't work with GeoServer OSEO STAC API #745

EetuHuuskoCSC opened this issue Oct 22, 2024 · 1 comment · Fixed by #746
Assignees
Labels
bug Something isn't working

Comments

@EetuHuuskoCSC
Copy link

We have an issue with using pystac-client with our GeoServer OSEO STAC API.
The Client.get_collection() function doesn't work as it assumes there are no query parameters in the URL and builds the URL manually based on that.

The generated URL looks like <host-adress>/geoserver/ogc/stac/v1/collections?f=application%2Fjson/<collection-id> where ?f=application%2Fjson is left in the middle.

import pystac_client

catalog_client = pystac_client.Client.open("https://paituli.csc.fi/geoserver/ogc/stac/v1")
collection = catalog_client.get_collection("sentinel2-l2a")
Traceback (most recent call last):
  File "/home/ehuusko/Documents/paituli/stac/testing_get_colletion.py", line 6, in <module>
    catalog_client.get_collection('sentinel2-l2a')
  File "/home/ehuusko/miniconda3/envs/paituli-stac/lib/python3.12/site-packages/pystac_client/client.py", line 399, in get_collection
    self._stac_io.read_json(url),
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ehuusko/miniconda3/envs/paituli-stac/lib/python3.12/site-packages/pystac/stac_io.py", line 205, in read_json
    txt = self.read_text(source, *args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ehuusko/miniconda3/envs/paituli-stac/lib/python3.12/site-packages/pystac_client/stac_api_io.py", line 168, in read_text
    return self.request(href, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ehuusko/miniconda3/envs/paituli-stac/lib/python3.12/site-packages/pystac_client/stac_api_io.py", line 217, in request
    raise APIError.from_response(resp)
pystac_client.exceptions.APIError: {"code":"NoApplicableCode","description":"Invalid mime type \"application/json/sentinel2-l2a\": Invalid token character '/' in token \"json/sentinel2-l2a\"\nInvalid mime type \"application/json/sentinel2-l2a\": Invalid token character '/' in token \"json/sentinel2-l2a\""}

Using pystac.catalog.Catalog.get_child() works:

import pystac

catalog = pystac.catalog.Catalog.from_file("https://paituli.csc.fi/geoserver/ogc/stac/v1")
collection = catalog.get_child("sentinel2-l2a")
<Collection id=sentinel2-l2a>
@gadomski gadomski self-assigned this Oct 22, 2024
@gadomski gadomski added the bug Something isn't working label Oct 22, 2024
@gadomski
Copy link
Member

Thanks for the report! PR to fix here: #746

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants