Skip to content
This repository was archived by the owner on Sep 23, 2024. It is now read-only.
This repository was archived by the owner on Sep 23, 2024. It is now read-only.

Error inferring datetime when data has no geometry #5

@barbuz

Description

@barbuz

I use stac-table to generate metadata for geospatial datasets, but once in a while I need to manage parquet files without a geometry column. This works fine with stac-table by setting proj=False, unless I also need to infer datetime information, in which case the generation fails.

Sample code to reproduce the issue:

import datetime
import pandas as pd
import pystac
import stac_table

# Create a sample DataFrame
data = {
    'time': pd.date_range(start='2022-01-01', periods=5, freq='H'),
    'value1': [1, 2, 3, 4, 5],
    'value2': [10, 20, 30, 40, 50],
}
df = pd.DataFrame(data)

# Save DataFrame to Parquet
df.to_parquet('sample.parquet')

# Item template
template = pystac.Item(
    "test",
    geometry=None,
    bbox=None,
    datetime=datetime.datetime.now(datetime.timezone.utc),
    properties={},
)

# Create a STAC Table
stac_table.generate(
    'sample.parquet',
    template,
    proj=False,
    infer_datetime=stac_table.InferDatetimeOptions.range,
    datetime_column='time',
)

When running I get this error:

ValueError: An error occurred while calling the read_parquet method registered to the pandas backend.
Original Message: Missing geo metadata in Parquet/Feather file.
Use pandas.read_parquet/read_feather() instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions