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

Error inferring datetime when data has no geometry #5

Open
barbuz opened this issue Feb 26, 2024 · 0 comments · May be fixed by #6
Open

Error inferring datetime when data has no geometry #5

barbuz opened this issue Feb 26, 2024 · 0 comments · May be fixed by #6

Comments

@barbuz
Copy link

barbuz commented Feb 26, 2024

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.

@barbuz barbuz linked a pull request Feb 26, 2024 that will close this issue
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant