Fiona
Fiona copied to clipboard
Provide Geo Interface for Collection and Records
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 https://github.com/altair-viz/altair/pull/1664) super duper easy.
✌️🥳🎉
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.
Do you worry about memory issues or is there another reason that this could be problematic?
@mattijn Would features be enough for Altair support?
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))
Still tracking this for 1.9.0.
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.
Done!