Skip to content

Helpers for working with STAC Catalogs via Pandas DataFrames

License

Notifications You must be signed in to change notification settings

azavea/stacframes

Repository files navigation

STACFrames

A Python library for working with STAC Catalogs via Pandas DataFrames

Installation

Install via pip:

pip install git+https://github.com/azavea/stacframes.git@dd7959d1a9fee7227624aa185f797402209b0ad0

Usage

To load a STAC Catalog into a GeoDataFrame:

import pystac
import stacframes

catalog = pystac.Catalog.from_file("path/to/catalog.json")
df = stacframes.df_from(catalog)

To write a DataFrame to a STAC Catalog:

from datetime import datetime, timezone
import pandas as pd
import pystac
from shapely.geometry import box
import stacframes

df = pd.read_csv("path/to/data.csv")

# Filter, map, edit dataframe as desired

# Map dataframe rows
def map_row_to_item(series):

    # Get and transform necessary column values from series
    geometry = series["geom"]
    dt = series["event_time"]

    return {
      "id": series["uuid"]
      "geometry": geometry
      "bbox": list(geometry.bounds)
      "datetime": dt
    }

catalog = pystac.Catalog("data", "My Data")
stacframes.df_to(catalog, df.apply(map_row_to_item))
catalog.normalize_and_save("./path/to/catalog.json")

Please take a look at the source code for more examples and additional documentation.

Developing

Install the development requirements:

pip install -r requirements-dev.txt

Make changes as desired, then run:

./scripts/test

Releasing a new version

Follow the checklist in RELEASE.md

About

Helpers for working with STAC Catalogs via Pandas DataFrames

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published