Skip to content

V2: Constructing item from geometry with tuple coords #1706

@tylanderson

Description

@tylanderson

Constructing an item from a shapely derived mapping results in validation errors when calling item.validate()

Example:

import shapely
from pystac import Item
import datetime


geom = shapely.from_wkt("POLYGON ((-95.780872 29.517294, -95.783782 29.623358, -96.041791 29.617689, -96.038613 29.511649, -95.780872 29.517294))")
bbox = geom.bounds
geojson = shapely.geometry.mapping(geom)
item = Item(
    id="some_id",
    geometry=geojson,
    bbox=bbox,
    datetime=datetime.datetime.now(),
    properties={},
)
item.validate()

yields an error as coords are expected to validate as lists:

pystac.errors.STACValidationError: {'type': 'Polygon', 'coordinates': (((-95.780872, 29.517294), (-95.783782, 29.623358), (-96.041791, 29.617689), (-96.038613, 29.511649), (-95.780872, 29.517294)),)} is not valid under any of the given schemas...

Surfaced from testing migration to v2 using stactools as test case

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions