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 Feature properties. The properties argument can be used to override these defaults. Nested values can be accessed with dot notation, for example taxon.name.

Parameters:
  • filename (Union[Path, str, None]) – An optional path to write the GeoJSON to

  • properties (List[str]) – A list of observation attributes to include as GeoJSON properties

Return type:

Optional[FeatureCollection]

Returns:

A FeatureCollection containing observation results as Feature dicts (if no filename is provided)