Fiona icon indicating copy to clipboard operation
Fiona copied to clipboard

Provide Geo Interface for Collection and Records

Open kannes opened this issue 6 years ago • 3 comments

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.

✌️🥳🎉

kannes avatar Sep 05 '19 09:09 kannes

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.

sgillies avatar Jul 04 '20 23:07 sgillies

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

@mattijn Would features be enough for Altair support?

kannes avatar Jul 06 '20 20:07 kannes

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))

mattijn avatar Jul 07 '20 08:07 mattijn

Still tracking this for 1.9.0.

sgillies avatar Dec 13 '22 22:12 sgillies

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 avatar Jan 22 '23 17:01 sgillies

you

kannes avatar Jan 23 '23 17:01 kannes

Done!

sgillies avatar Jan 26 '23 20:01 sgillies