GeoJSON¶
pyinaturalist_convert.geojson
Convert observations to GeoJSON FeatureCollections.
Extra dependencies: geojson
Example:
>>> from pyinaturalist import iNatClient
>>> from pyinaturalist_convert import to_geojson
>>> # Get all georeferenced observations made within 2km of Neal Smith Wildlife Refuge
>>> client = iNatClient()
>>> observations = client.observations.search(lat=41.55958, lng=-93.27904, radius=2).all()
>>> # Convert to GeoJSON
>>> geojson = to_geojson(observations)
- pyinaturalist_convert.geojson.to_geojson(observations, filename=None, properties=['id', 'photo_url', 'positional_accuracy', 'quality_grade', 'taxon.id', 'taxon.name', 'taxon.preferred_common_name', 'observed_on', 'uri'])¶
Convert observations to a GeoJSON FeatureCollection.
By default this includes some basic observation attributes as GeoJSON
Featureproperties. Thepropertiesargument can be used to override these defaults. Nested values can be accessed with dot notation, for exampletaxon.name.- Parameters:
- Return type:
Optional[FeatureCollection]- Returns:
A
FeatureCollectioncontaining observation results asFeaturedicts (if no filename is provided)