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

Add to_geopandas() method #38

Merged
merged 13 commits into from
Feb 5, 2020
Merged

Add to_geopandas() method #38

merged 13 commits into from
Feb 5, 2020

Conversation

andersy005
Copy link
Member

@andersy005 andersy005 commented Jan 17, 2020

Towards #36

@jhamman
Copy link
Collaborator

jhamman commented Jan 21, 2020

pinging @scottyhq and @matthewhanson for review/comment.

@matthewhanson
Copy link
Collaborator

This looks good to me

intake_stac/catalog.py Outdated Show resolved Hide resolved

cat = StacItemCollection(stac_item_collection_obj)
df = cat.to_geopandas()
assert isinstance(df, gpd.GeoDataFrame)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we also assert that the new df has a few features that we expect (e.g. number or rows, index values, etc.)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. I added a few more tests to address this

@scottyhq
Copy link
Collaborator

scottyhq commented Jan 22, 2020

Thanks @andersy005 for moving this forward. I think it's a helpful start, but we shouldn't close issue 36 yet because it would be great to have some sort of querying and indexing directly on the catalog as described by Joe
#36 (comment)

Some other things to be aware of are changes to the STAC JSON that can affect this functionality. We should add tests that reflect the STAC version being used and maybe in the near future just enforce using STAC>0.9. It works currently because we're using @matthewhanson's satstac library which saves a self-contained STAC catalog as geojson "FeatureCollection" (which can be read by geopandas) - radiantearth/stac-spec#691

gf = gpd.GeoDataFrame.from_features(cat._stac_obj.geojson(), crs={'init' :'epsg:4326'})

Finally, we'll want to read CRS from the STAC catalog if it exists, and if not assign EPSG:4326 which is the usual. https://github.com/radiantearth/stac-spec/tree/master/extensions/projection

How geopandas handles CRS might change in 0.7 geopandas/geopandas#1003

@andersy005
Copy link
Member Author

Finally, we'll want to read CRS from the STAC catalog if it exists, and if not assign EPSG:4326 which is the usual.

If I understand this correctly, extracting the CRS from the STAC catalog for catalogs that use the commons extension should be straightforward since the CRS is likely to be among the common metadata fields. What should we do in those cases where the commons extension is not used i.e. the CRS field is included on every Item? Do we just pick one item from the collection and assume that its CRS field is common for the rest of the items?

@andersy005
Copy link
Member Author

I think it's a helpful start, but we shouldn't close issue 36 yet because it would be great to have some sort of querying and indexing directly on the catalog as described by Joe
#36 (comment)

Happy to work on this as part of this PR

intake_stac/catalog.py Outdated Show resolved Hide resolved
@andersy005 andersy005 changed the title Add to_/from_geopandas methods Add to_geopandas() method Feb 5, 2020
@jhamman jhamman merged commit f74a8f3 into intake:master Feb 5, 2020
@jhamman
Copy link
Collaborator

jhamman commented Feb 5, 2020

Thanks @andersy005!

@andersy005 andersy005 deleted the to-from-geopandas branch February 5, 2020 04:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants