Geospatial
Note
Check https://github.com/cognitedata/geospatial-examples for some complete examples.
Feature types
Features
Reference systems
Raster data
Geospatial Data classes
- class cognite.client.data_classes.geospatial.CoordinateReferenceSystem(srid: int, wkt: str, proj_string: str)
Bases:
CoordinateReferenceSystemCoreA representation of a feature in the geospatial API. This is the read version of the CoordinateReferenceSystem class, it is used when retrieving from the CDF.
- Parameters:
srid (int) – EPSG code, e.g., 4326. Only valid for geometry types. See https://en.wikipedia.org/wiki/Spatial_reference_system
wkt (str) – Well-known text of the geometry, see https://docs.geotools.org/stable/javadocs/org/opengis/referencing/doc-files/WKT.html
proj_string (str) – The projection specification string as described in https://proj.org/usage/quickstart.html
- as_write() CoordinateReferenceSystemWrite
Returns a write version of this coordinate reference system.
- class cognite.client.data_classes.geospatial.CoordinateReferenceSystemCore(srid: int, wkt: str, proj_string: str)
Bases:
WriteableCogniteResource[CoordinateReferenceSystemWrite],ABCA representation of a feature in the geospatial API.
- Parameters:
srid (int) – EPSG code, e.g., 4326. Only valid for geometry types. See https://en.wikipedia.org/wiki/Spatial_reference_system
wkt (str) – Well-known text of the geometry, see https://docs.geotools.org/stable/javadocs/org/opengis/referencing/doc-files/WKT.html
proj_string (str) – The projection specification string as described in https://proj.org/usage/quickstart.html
- class cognite.client.data_classes.geospatial.CoordinateReferenceSystemList(
- resources: Sequence[T_CogniteResource],
Bases:
WriteableCogniteResourceList[CoordinateReferenceSystemWrite,CoordinateReferenceSystem]
- class cognite.client.data_classes.geospatial.CoordinateReferenceSystemWrite(srid: int, wkt: str, proj_string: str)
Bases:
CoordinateReferenceSystemCoreA representation of a feature in the geospatial API.
- Parameters:
srid (int) – EPSG code, e.g., 4326. Only valid for geometry types. See https://en.wikipedia.org/wiki/Spatial_reference_system
wkt (str) – Well-known text of the geometry, see https://docs.geotools.org/stable/javadocs/org/opengis/referencing/doc-files/WKT.html
proj_string (str) – The projection specification string as described in https://proj.org/usage/quickstart.html
- as_write() CoordinateReferenceSystemWrite
Returns this CoordinateReferenceSystemWrite instance.
- class cognite.client.data_classes.geospatial.CoordinateReferenceSystemWriteList(
- resources: Sequence[T_CogniteResource],
- class cognite.client.data_classes.geospatial.Feature(
- external_id: str | None,
- created_time: int | None,
- last_updated_time: int | None,
- data_set_id: int | None,
- **properties: Any,
Bases:
FeatureCoreA representation of a feature in the geospatial API. This is the read version of the Feature class, it is used when retrieving features from the api.
- Parameters:
external_id (str | None) – The external ID provided by the client. Must be unique for the resource type.
created_time (int | None) – No description.
last_updated_time (int | None) – No description.
data_set_id (int | None) – No description.
**properties (Any) – The properties of the feature.
- as_write() FeatureWrite
Returns a write version of this feature.
- class cognite.client.data_classes.geospatial.FeatureAggregate
Bases:
CogniteResourceA result of aggregating features in geospatial API.
- class cognite.client.data_classes.geospatial.FeatureAggregateList(
- resources: Sequence[T_CogniteResource],
Bases:
CogniteResourceList[FeatureAggregate]
- class cognite.client.data_classes.geospatial.FeatureCore(external_id: str | None, **properties: Any)
Bases:
WriteableCogniteResource[FeatureWrite],ABCA representation of a feature in the geospatial API.
- Parameters:
external_id (str | None) – The external ID provided by the client. Must be unique for the resource type.
**properties (Any) – The properties of the feature.
- dump(camel_case: bool = True) dict[str, Any]
Dump the instance into a json serializable Python data type.
- Parameters:
camel_case (bool) – Use camelCase for attribute names. Defaults to True.
- Returns:
A dictionary representation of the instance.
- Return type:
dict[str, Any]
- class cognite.client.data_classes.geospatial.FeatureList(
- resources: Sequence[T_CogniteResource],
Bases:
FeatureListCore[Feature]
- class cognite.client.data_classes.geospatial.FeatureListCore(
- resources: Sequence[T_CogniteResource],
Bases:
WriteableCogniteResourceList[FeatureWrite,T_Feature],ExternalIDTransformerMixin- static from_geopandas(
- feature_type: FeatureType,
- geodataframe: geopandas.GeoDataFrame,
- external_id_column: str = 'externalId',
- property_column_mapping: dict[str, str] | None = None,
- data_set_id_column: str = 'dataSetId',
Convert a GeoDataFrame instance into a FeatureList.
- Parameters:
feature_type (FeatureType) – The feature type the features will conform to
geodataframe (geopandas.GeoDataFrame) – the geodataframe instance to convert into features
external_id_column (str) – the geodataframe column to use for the feature external id
property_column_mapping (dict[str, str] | None) – provides a mapping from featuretype property names to geodataframe columns
data_set_id_column (str) – the geodataframe column to use for the feature dataSet id
- Returns:
The list of features converted from the geodataframe rows.
- Return type:
Examples
Create features from a geopandas dataframe:
>>> from cognite.client import CogniteClient, AsyncCogniteClient >>> client = CogniteClient() >>> # async_client = AsyncCogniteClient() # another option >>> my_feature_type = ( ... ... ... ) # some feature type with 'position' and 'temperature' properties >>> my_geodataframe = ... # some geodataframe with 'center_xy', 'temp' and 'id' columns >>> feature_list = FeatureList.from_geopandas(feature_type=my_feature_type, geodataframe=my_geodataframe, >>> external_id_column="id", data_set_id_column="dataSetId", >>> property_column_mapping={'position': 'center_xy', 'temperature': 'temp'}) >>> created_features = client.geospatial.create_features( ... my_feature_type.external_id, feature_list ... )
- to_geopandas(
- geometry: str,
- camel_case: bool = False,
Convert the instance into a GeoPandas GeoDataFrame.
- Parameters:
geometry (str) – The name of the feature type geometry property to use in the GeoDataFrame
camel_case (bool) – Convert column names to camel case (e.g. externalId instead of external_id)
- Returns:
The GeoPandas GeoDataFrame.
- Return type:
geopandas.GeoDataFrame
Examples
Convert a FeatureList into a GeoPandas GeoDataFrame:
>>> from cognite.client.data_classes.geospatial import PropertyAndSearchSpec >>> from cognite.client import CogniteClient, AsyncCogniteClient >>> client = CogniteClient() >>> # async_client = AsyncCogniteClient() # another option >>> features = client.geospatial.search_features(...) >>> gdf = features.to_geopandas(geometry="position", camel_case=False) >>> gdf.head()
- class cognite.client.data_classes.geospatial.FeatureType(
- external_id: str,
- created_time: int,
- last_updated_time: int,
- properties: dict[str, Any],
- data_set_id: int | None = None,
- search_spec: dict[str, Any] | None = None,
Bases:
FeatureTypeCoreA representation of a feature type in the geospatial API. This is the read version of the FeatureType class, it is used when retrieving feature types from the api.
- Parameters:
external_id (str) – The external ID provided by the client. Must be unique for the resource type.
created_time (int) – The created time of the feature type.
last_updated_time (int) – The last updated time of the feature type.
properties (dict[str, Any]) – The properties of the feature type.
data_set_id (int | None) – The ID of the dataset this feature type belongs to.
search_spec (dict[str, Any] | None) – The search spec of the feature type.
- as_write() FeatureTypeWrite
Returns a write version of this feature type.
- class cognite.client.data_classes.geospatial.FeatureTypeCore(
- external_id: str,
- data_set_id: int | None,
- properties: dict[str, Any],
- search_spec: dict[str, Any] | None,
Bases:
WriteableCogniteResource[FeatureTypeWrite],ABCA representation of a feature type in the geospatial API.
- Parameters:
external_id (str) – The external ID provided by the client. Must be unique for the resource type.
data_set_id (int | None) – The ID of the dataset this feature type belongs to.
properties (dict[str, Any]) – The properties of the feature type.
search_spec (dict[str, Any] | None) – The search spec of the feature type.
- class cognite.client.data_classes.geospatial.FeatureTypeList(
- resources: Sequence[T_CogniteResource],
Bases:
WriteableCogniteResourceList[FeatureTypeWrite,FeatureType],ExternalIDTransformerMixin
- class cognite.client.data_classes.geospatial.FeatureTypePatch(
- external_id: 'str | None' = None,
- property_patches: 'Patches | None' = None,
- search_spec_patches: 'Patches | None' = None,
Bases:
CogniteResource- dump(camel_case: bool = True) dict[str, Any]
Dump the instance into a json serializable Python data type.
- Parameters:
camel_case (bool) – Use camelCase for attribute names. Defaults to True.
- Returns:
A dictionary representation of the instance.
- Return type:
dict[str, Any]
- class cognite.client.data_classes.geospatial.FeatureTypeWrite(
- external_id: str,
- properties: dict[str, Any],
- data_set_id: int | None = None,
- search_spec: dict[str, Any] | None = None,
Bases:
FeatureTypeCoreA representation of a feature type in the geospatial API. This is the write version of the FeatureType class, it is used when creating feature types in the api.
- Parameters:
external_id (str) – The external ID provided by the client. Must be unique for the resource type.
properties (dict[str, Any]) – The properties of the feature type.
data_set_id (int | None) – The ID of the dataset this feature type belongs to.
search_spec (dict[str, Any] | None) – The search spec of the feature type.
- as_write() FeatureTypeWrite
Returns this FeatureTypeWrite instance.
- class cognite.client.data_classes.geospatial.FeatureTypeWriteList(
- resources: Sequence[T_CogniteResource],
Bases:
CogniteResourceList[FeatureTypeWrite],ExternalIDTransformerMixin
- class cognite.client.data_classes.geospatial.FeatureWrite(external_id: str, **properties: Any)
Bases:
FeatureCoreA representation of a feature in the geospatial API. This is the write version of the Feature class, it is used when creating features in the api.
- Parameters:
external_id (str) – The external ID provided by the client. Must be unique for the resource type.
**properties (Any) – The properties of the feature.
- as_write() FeatureWrite
Returns this FeatureWrite instance.
- class cognite.client.data_classes.geospatial.FeatureWriteList(
- resources: Sequence[T_CogniteResource],
Bases:
FeatureListCore[FeatureWrite]
- class cognite.client.data_classes.geospatial.GeospatialComputeFunction
Bases:
ABCA geospatial compute function
- abstract to_json_payload() dict
Convert function to json for request payload
- class cognite.client.data_classes.geospatial.GeospatialComputedItem(resource: dict[str, Any])
Bases:
CogniteResourceA representation of an item computed from geospatial.
- class cognite.client.data_classes.geospatial.GeospatialComputedItemList(
- resources: Sequence[T_CogniteResource],
Bases:
CogniteResourceList[GeospatialComputedItem]A list of items computed from geospatial.
- class cognite.client.data_classes.geospatial.GeospatialComputedResponse(
- computed_item_list: GeospatialComputedItemList,
Bases:
CogniteResourceThe geospatial compute response.
- dump(
- camel_case: bool = True,
Dump the instance into a json serializable Python data type.
- Parameters:
camel_case (bool) – Use camelCase for attribute names. Defaults to True.
- Returns:
A dictionary representation of the instance.
- Return type:
dict[str, Any]
- class cognite.client.data_classes.geospatial.GeospatialGeometryComputeFunction
Bases:
GeospatialComputeFunction,ABCA geospatial geometry compute function
- class cognite.client.data_classes.geospatial.GeospatialGeometryTransformComputeFunction(
- geospatial_geometry_compute_function: GeospatialComputeFunction,
- srid: int,
Bases:
GeospatialComputeFunctionA stTransform geospatial compute function
- to_json_payload() dict
Convert function to json for request payload
- class cognite.client.data_classes.geospatial.GeospatialGeometryValueComputeFunction(ewkt: str)
Bases:
GeospatialGeometryComputeFunctionA geospatial geometry value compute function. Accepts a well-known text of the geometry prefixed with a spatial reference identifier, see https://docs.geotools.org/stable/javadocs/org/opengis/referencing/doc-files/WKT.html
- Parameters:
ewkt (str) – No description.
- to_json_payload() dict
Convert function to json for request payload
- class cognite.client.data_classes.geospatial.OrderSpec(property: str, direction: str)
Bases:
objectAn order specification with respect to an property.
- class cognite.client.data_classes.geospatial.Patches(add: 'dict[str, Any] | None' = None, remove: 'list[str] | None' = None)
Bases:
CogniteResource
- class cognite.client.data_classes.geospatial.PropertyAndSearchSpec(
- properties: dict[str, Any] | list[str] | None = None,
- search_spec: dict[str, Any] | list[str] | None = None,
Bases:
CogniteResourceA representation of a feature type property and search spec.
- class cognite.client.data_classes.geospatial.RasterMetadata(**properties: Any)
Bases:
objectRaster metadata
- cognite.client.data_classes.geospatial.nan_to_none(column_value: Any) Any
Convert NaN value to None.