Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[flake8]
max-line-length = 100
33 changes: 33 additions & 0 deletions .github/workflows/continuous-integration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: CI

on:
push:
branches:
- develop
- master
pull_request:

jobs:
build:
name: build
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.6", "3.7", "3.8"]
steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Cache dependencies
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: pip-${{ hashFiles('requirements-dev.txt') }}
restore-keys: pip-

- name: Execute linters and test suites
run: ./scripts/cibuild
33 changes: 33 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Release

on:
push:
tags:
- "*"

jobs:
release:
name: release
runs-on: ubuntu-latest
steps:
- name: Checkout commit and fetch tag history
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up Python 3.x
uses: actions/setup-python@v2
with:
python-version: "3.x"

- name: Install release dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish package
env:
TWINE_USERNAME: ${{ secrets.PYPI_AZAVEA_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_AZAVEA_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
129 changes: 129 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [0.1.0] - 2020-11-06

### Added

- Initial release

[Unreleased]: https://github.com/azavea/pystac-io/compare/0.1.0...HEAD
[0.1.0]: https://github.com/azavea/pystac-io/releases/tag/0.1.0
71 changes: 71 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,74 @@

A Python library for working with STAC Catalogs via Pandas DataFrames

## Installation

Install via pip:

```shell
pip install stacframes
```

## Usage

To load a STAC Catalog into a GeoDataFrame:

```python
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:

```python
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](https://github.com/azavea/stacframes/blob/master/stacframes/__init__.py) for more examples and additional documentation.

## Developing

Install the development requirements:

```shell
pip install -r requirements-dev.txt
```

Make changes as desired, then run:

```shell
./scripts/test
```

## Releasing a new version

Follow the checklist in [RELEASE.md](./RELEASE.md)
11 changes: 11 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Release Checklist

- [ ] Create new branch `release/x.y.z`
- [ ] Update CHANGELOG.md and commit changes
- [ ] Update version in `setup.py` to match release and commit changes
- [ ] Open PR with title "Release X.Y.Z" and ensure tests pass
- [ ] Once tests have passed, merge PR
- [ ] Pull master and create tag `git tag -a x.y.z -m "vX.Y.Z"`
- [ ] `git push --tags`
- [ ] Wait for and ensure that release build succeeds and publishes new package to https://pypi.org

1 change: 1 addition & 0 deletions examples/aviris/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
catalog
15 changes: 15 additions & 0 deletions examples/aviris/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# AVIRIS Example

This example uses `stacframes` to construct a STAC Catalog for the [NASA JPL AVIRIS dataset](https://aviris.jpl.nasa.gov).

It requires the following python packages to run:

```shell
stacframes
fastkml
jsonschema
```

Open a terminal in this directory, then generate the catalog with `python main.py`.

The catalog will be written to `./catalog/catalog.json`.
Loading