Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add STAC item id to geopandas #158

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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
6 changes: 1 addition & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,8 @@ repos:
rev: 6.0.0
hooks:
- id: flake8
- repo: https://github.com/asottile/seed-isort-config
rev: v2.2.0
hooks:
- id: seed-isort-config
- repo: https://github.com/PyCQA/isort
rev: 5.11.4
rev: 5.12.0
hooks:
- id: isort

Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## Unreleased

- Add STAC item id to GeoDataFrame when calling `to_geopandas()` method (#158)

## [v0.4.0] - 2021-XX-XX

- Switched from sat-stac to pystac dependency (#72)
Expand Down
1 change: 1 addition & 0 deletions ci/environment-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ dependencies:
- pystac-client
- pytest-cov
- rasterio
- rioxarray
- scikit-image
- sphinx
- sphinx_rtd_theme
Expand Down
6 changes: 3 additions & 3 deletions docs/source/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,15 @@ using `pystac-client`:
.. ipython:: python

import pystac_client
URL = "https://earth-search.aws.element84.com/v0"
URL = "https://earth-search.aws.element84.com/v1"
catalog = pystac_client.Client.open(URL)

results = catalog.search(
collections=["sentinel-s2-l2a-cogs"],
collections=["sentinel-2-l2a"],
bbox = [35.48, -3.24, 35.58, -3.14],
datetime="2020-07-01/2020-08-15")

items = results.get_all_items()
items = results.item_collection()
print(len(items))

In the code section above, `items` is a `pystac.ItemsCollection` object.
Expand Down
7 changes: 7 additions & 0 deletions intake_stac/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,13 @@ def to_geopandas(self, crs=None):
if crs is None:
crs = 'epsg:4326'
gf = gpd.GeoDataFrame.from_features(self._stac_obj.to_dict(), crs=crs)

# If no id in properties, use the STAC item id
if 'id' not in gf.columns:
items = self._stac_obj.items
item_ids = [item.id for item in items]
gf['id'] = item_ids

return gf


Expand Down