GeoDataFrame.iterfeatures(na='null', show_bbox=False, drop_id=False)

Returns an iterator that yields feature dictionaries that comply with __geo_interface__

nastr, optional

Options are {‘null’, ‘drop’, ‘keep’}, default ‘null’. Indicates how to output missing (NaN) values in the GeoDataFrame * null: ouput the missing entries as JSON null * drop: remove the property from the feature. This applies to

each feature individually so that features may have different properties

  • keep: output the missing entries as NaN

show_bboxbool, optional

Include bbox (bounds) in the geojson. Default False.

drop_idbool, default: False

Whether to retain the index of the GeoDataFrame as the id property in the generated GeoJSON. Default is False, but may want True if the index is just arbitrary row numbers.


>>> from shapely.geometry import Point
>>> d = {'col1': ['name1', 'name2'], 'geometry': [Point(1, 2), Point(2, 1)]}
>>> gdf = geopandas.GeoDataFrame(d, crs="EPSG:4326")
>>> gdf
    col1                 geometry
0  name1  POINT (1.00000 2.00000)
1  name2  POINT (2.00000 1.00000)
>>> feature = next(gdf.iterfeatures())
>>> feature
{'id': '0', 'type': 'Feature', 'properties': {'col1': 'name1'}, 'geometry': {'type': 'Point', 'coordinates': (1.0, 2.0)}}