Developer Interface¶
Main Interface¶
resolver.py
The primary client-facing API for resolving spatial geometries to environmental descriptions.
- class geoenv.resolver.Resolver(data_source: List[DataSource])[source]¶
The Resolver class serves as the primary client-facing API for querying environmental data. Clients configure an instance with one or more
DataSourceobjects and use theresolvemethod to retrieve environment descriptions based on geographic locations.The results are mapped to a specified semantic resource (default: ENVO) and returned in a structured
Responseobject.- async resolve(geometry: Geometry, semantic_resource: str = 'ENVO', identifier: str = None, description: str = None) Response[source]¶
Resolves a given
Geometryto one or more environments using the configured data sources. The results are mapped to a semantic resource (e.g., ENVO) and returned as aResponseobject.- Parameters:
geometry – The spatial geometry to resolve.
semantic_resource – The semantic resource to use for mapping (default: “ENVO”).
identifier – An optional identifier for tracking the resolution request.
description – An optional description to annotate the resolution request.
- Returns:
A
Responseobject containing the resolved environmental data.
Data Sources¶
- class geoenv.data_sources.WorldTerrestrialEcosystems(grid_size: float = None)[source]¶
A concrete implementation of
DataSourcethat retrieves terrestrial ecosystem classifications from the World Terrestrial Ecosystems dataset (Sayre 2022).- Note
This data source only accepts
Pointgeometries directly.Polygongeometries are supported indirectly via thegrid_sizeproperty, which enables subsampling of the polygon into representative points. Each point is resolved individually, and the results are aggregated into the final response. By default,Polygongeometries are resolved using the centroid of the polygon.
- Further Information
Spatial Resolution: Global coverage with a resolution of 250 meters.
Coverage: Terrestrial ecosystems worldwide, classified by land cover, landform, and climate.
Explore the Dataset: https://www.arcgis.com/home/item.html?id= 926a206393ec40a590d8caf29ae9a93e.
- Citation
Sayre, R., 2022, World Terrestrial Ecosystems (WTE) 2020: U.S. Geological Survey data release, https://doi.org/10.5066/P9DO61LP.
- property grid_size: float¶
Retrieves the grid size used for spatial resolution. The size of the grid cells are in the same units as the geometry coordinates.
Note, if a
Polygongeometry is provided, this property determines the spacing of the representative points used for subsampling. Each point is resolved individually, and the results are combined in the final response.- Returns:
The grid size as a float.
- class geoenv.data_sources.EcologicalCoastalUnits(buffer: float = None)[source]¶
A concrete implementation of
DataSourcethat retrieves coastal environmental classifications from the Ecological Coastal Units dataset (Sayre 2023).- Note
Note, this data source does not accept
Pointgeometries directly. Because coastal units are represented as vector polygons, input geometries must overlap with them for successful resolution. However,Pointgeometries can be processed by setting thebufferproperty, which converts them into circular polygons of a given radius (in kilometers). These polygons are then resolved against the dataset, and all overlapping coastal units are returned in the response.
- Further Information
Spatial Resolution: Global coverage with a resolution of 1 km (or shorter).
Coverage: Costal ecosystems worldwide, classified by sinuosity, erodibility, temperature and moisture regime, river discharge, wave height, tidal range, marine physical environment, turbidity, and chlorophyll.
Explore the Dataset: https://www.arcgis.com/home/item.html?id= 54df078334954c5ea6d5e1c34eda2c87.
- Citation
Sayre, R., 2023, Global Ecological Classification of Coastal Segment Units: U.S. Geological Survey data release, https://doi.org/10.5066/P9HWHSPU.
- property buffer: float¶
Retrieves the buffer distance used for spatial resolution.
Since this data source does not accept
Pointgeometries directly, setting thebufferparameter converts them into circular polygons of a given radius (in kilometers) before resolution. All overlapping coastal units within the buffered area will be included in the response.- Returns:
The buffer radius as a float. Units are in kilometers.
- class geoenv.data_sources.EcologicalMarineUnits[source]¶
A concrete implementation of
DataSourcethat retrieves marine environmental classifications from the Ecological Marine Units dataset (Sayre 2023).- Note
This data source supports the resolution of geometries with
zvalues (depth). To retrieve environmental data at different depths, include thezcomponent in the input geometry. No additional property is required.If no
zvalue is specified in the geometry, all vertically stacked environments will be returned. If azvalue is included, only the intersecting environment layers at that depth will be returned.
- Further Information
Spatial Resolution: Global coverage with a resolution of 1/4 degree.
Coverage: Marine ecosystems worldwide, classified by ocean name, depth, temperature, salinity, dissolved oxygen, nitrate, phosphate, and silicate.
Explore the Dataset: https://esri.maps.arcgis.com/home/item.html? id=58526e3af88b46a3a1d1eb1738230ee3.
- Citation
Sayre, R., 2023, Ecological Marine Units (EMUs): U.S. Geological Survey data release, https://doi.org/10.5066/P9Q6ZSGN.
Geometry¶
geometry.py
- class geoenv.geometry.Geometry(geometry: dict)[source]¶
The Geometry class manages spatial geometries in GeoJSON format and provides utilities for transformation and spatial processing.
Currently, the
geometryparameter only supports GeoJSONPointandPolygontypes, with plans to support additional types, includingGeometryCollection, in the future.- property data: dict¶
Retrieves the stored geometry data.
- Returns:
A dictionary representing the GeoJSON geometry.
- geometry_type() str[source]¶
Retrieves the type of the stored geometry (e.g., “Point” or “Polygon”).
- Returns:
A string representing the geometry type.
- is_supported() bool[source]¶
Checks if the stored geometry is supported by the resolver. A valid geometry must be a GeoJSON object with a top-level
typeof either “Point” or “Polygon”.- Returns:
Trueif the geometry is supported, otherwiseFalse.
- point_to_polygon(buffer=None) dict[source]¶
Converts a
Pointgeometry into aPolygonby buffering it.- Parameters:
buffer – The buffer distance used to create the polygon (optional).
- Returns:
A dictionary representing the buffered polygon in GeoJSON format.
Response¶
response.py
- class geoenv.response.Response(data: dict = None)[source]¶
The Response class structures the results returned by the
Resolverinto a standardized format. The response follows the GeoJSON format, with resolved environments and their descriptions stored in thepropertiesfield.- apply_term_mapping(semantic_resource: str = 'ENVO') Response[source]¶
Maps environmental terms in the response data to a specified semantic resource.
- Parameters:
semantic_resource – The semantic resource for mapping (default: “ENVO”). Options include: “ENVO”.
- Returns:
The updated Response object with mapped terms.
- property data: dict¶
Retrieves the response data.
- Returns:
The response data as a dictionary.
- read(file_path: str) Response[source]¶
Reads response data from a JSON file and updates the object’s data.
- Parameters:
file_path – The file path from which to read response data.
- Returns:
The updated Response object.
Environment¶
environment.py
- class geoenv.environment.Environment(data: dict = None)[source]¶
The Environment class represents environmental descriptions retrieved from a
DataSource. It provides a structured way to store and manage environmental data.- property data: dict¶
Retrieves the stored environmental data.
- Returns:
A dictionary representing the environmental data.
Utilities¶
utilities.py