Skip to content

Extensions should coerce values to correct type #1044

Closed as not planned
Closed as not planned
@jsignell

Description

@jsignell

Specifically non-null values in "proj:epsg" and "proj:shape" should be coerced to int. Ideally this should happen on the properties field itself rather than only when directly getting the prop from the extension class

Context

I was debugging an issue on VEDA where epsg was being read as a float and causing some issues.

import pystac
from pystac.extensions.projection import ProjectionExtension

item = pystac.Item.from_file("https://staging-stac.delta-backend.com/collections/nceo_africa_2017/items/AGB_map_2017v0m_COG")
print(ProjectionExtension.has_extension(item))  # False
print(item.properties["proj:epsg"])  # 4326.0

I decided that maybe there was a mismatch between the STAC version and the extension version, so I pulled the file locally (using wget) and changed proj ext schema version from v1.0.0 to v1.1.0

import pystac
from pystac.extensions.projection import ProjectionExtension

item = pystac.Item.from_file("AGB_map_2017v0m_COG")
print(ProjectionExtension.has_extension(item))  # True
print(item.properties["proj:epsg"])  # 4326.0
print(ProjectionExtension.ext(item).epsg)  # 4326.0

This time the proj ext is understood , but in the process of pulling the file all my int fields were converted to floats. I think this is because json doesn't really understand the difference between ints and floats. but since my STAC entry contains floats rather than ints, the value is always a float. Even when getting it directly from the extension class.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThings which are brokenextensionImplement a STAC extension in PySTAC

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions