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

Provide Geo Interface for Collection and Records #785

Closed
kannes opened this issue Sep 5, 2019 · 7 comments
Closed

Provide Geo Interface for Collection and Records #785

kannes opened this issue Sep 5, 2019 · 7 comments
Assignees
Milestone

Comments

@kannes
Copy link
Contributor

kannes commented Sep 5, 2019

This is a feature request, not a bug report.

Please provide the __geo_interface__ property for both the whole Collection (mirroring GeoPandas approach of returning something like a GeoJSON FeatureCollection) and for each Record (like a GeoJSON Feature).

This would add Fiona to the fabulous list of projects supporting the Geo Interface and it would make plotting in Altair (thanks to the recent addition of vega/altair#1664) super duper easy.

✌️🥳🎉

@sgillies
Copy link
Member

sgillies commented Jul 4, 2020

We'll do this for features, but not for collections, which can be very large. Handling that situation is best left up to the fiona user.

@kannes
Copy link
Contributor Author

kannes commented Jul 6, 2020

Do you worry about memory issues or is there another reason that this could be problematic?

@mattijn Would features be enough for Altair support?

@mattijn
Copy link

mattijn commented Jul 7, 2020

A fiona.Collection is a Iterator, so the features are parsed one by one. For __geo_interface__ support you’ll have to return all features in once as a copy. That is a choice.

Currently a single fiona feature is just a plain dictionary. I don’t know many people who uses fiona that like to plot a single feature. So that is probably not so useful. To collect the features of interest in a list won’t help much since a plain list has no __geo_interface__.

So you’ll still need to create a FeatureCollection by yourself: geojson.FeatureCollection(list(fio_col))

@sgillies
Copy link
Member

Still tracking this for 1.9.0.

@sgillies
Copy link
Member

Geo interface for Feature is done. I've decided not to do anything about Collection. Very large feature collection blobs are, from this project's perspective, an anti-pattern. Fiona is more about streaming features. And as pointed out, it's only 1-2 lines of code to materialize a Collection.

sgillies added a commit that referenced this issue Jan 22, 2023
* Add __geo_interface__ to Feature

Resolves #785

* Update link in change log
@kannes
Copy link
Contributor Author

kannes commented Jan 23, 2023

you

@sgillies
Copy link
Member

Done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants