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 Item support with null geometry #847

Closed
1 of 8 tasks
kalxas opened this issue Feb 24, 2023 · 1 comment
Closed
1 of 8 tasks

STAC Item support with null geometry #847

kalxas opened this issue Feb 24, 2023 · 1 comment
Assignees
Labels
Milestone

Comments

@kalxas
Copy link
Member

kalxas commented Feb 24, 2023

Description

STAC Item spec says that geometry can be null and bbox is required if geometry is null.
https://github.com/radiantearth/stac-spec/blob/master/item-spec/item-spec.md

Test with a copy of https://github.com/radiantearth/stac-spec/blob/master/examples/simple-item.json
with no bbox and "geometry": null, throws the following error:

Error message
=========
Could not parse "/tmp/metadata" as an XML record

Traceback (most recent call last):

  File "/home/pycsw/pycsw/pycsw/core/admin.py", line 370, in load_records

    record = metadata.parse_record(context, metadata_record, repo)

  File "/home/pycsw/pycsw/pycsw/core/metadata.py", line 120, in parse_record

    return _parse_metadata(context, repos, record)

  File "/home/pycsw/pycsw/pycsw/core/metadata.py", line 135, in _parse_metadata

    return [_parse_json_record(context, repos, record)]

  File "/home/pycsw/pycsw/pycsw/core/metadata.py", line 1632, in _parse_json_record

    recobj = _parse_stac_item(context, repos, record)

  File "/home/pycsw/pycsw/pycsw/core/metadata.py", line 1751, in _parse_stac_item

    _set(context, recobj, 'pycsw:BoundingBox', util.bbox2wktpolygon(util.geojson_geometry2bbox(record['geometry'])))

  File "/home/pycsw/pycsw/pycsw/core/util.py", line 185, in geojson_geometry2bbox

    geom_type = geometry.get('type')

AttributeError: 'NoneType' object has no attribute 'get' 

Environment

  • operating system:
  • Python version:
  • pycsw version:
  • source/distribution
    • git clone
    • DebianGIS/UbuntuGIS
    • PyPI
    • zip/tar.gz
    • other (please specify): Docker (latest)
  • web server
    • Apache/mod_wsgi
    • CGI
    • other (please specify):
@tomkralidis
Copy link
Member

Looking at the STAC Item spec, I am interpreting the inverse (if geometry is not null, bbox is required), so that bbox provides a simple minimum bounding geometry if geometry is defined.

Having said this, I've reproduced the error and applied a fix as part of #991.

kalxas pushed a commit that referenced this issue Aug 4, 2024
* minor STAC API updates
* add tests for required link properties
* STAC API: add bbox is geometry is null (#847)
* safeguard null geometry handling on STAC parsing (#847)
* update geometry/bbox handling
@kalxas kalxas closed this as completed Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants