Geospatial

Note

Check https://github.com/cognitedata/geospatial-examples for some complete examples.

Feature types

AsyncCogniteClient.geospatial.create_feature_types(...)

Creates feature types.

AsyncCogniteClient.geospatial.delete_feature_types(...)

Delete one or more feature type.

AsyncCogniteClient.geospatial.list_feature_types()

List feature types.

AsyncCogniteClient.geospatial.retrieve_feature_types(...)

Retrieve feature types.

AsyncCogniteClient.geospatial.patch_feature_types(patch)

Patch feature types.

Features

AsyncCogniteClient.geospatial.create_features(...)

Creates features.

AsyncCogniteClient.geospatial.delete_features(...)

Delete one or more feature.

AsyncCogniteClient.geospatial.retrieve_features(...)

Retrieve features.

AsyncCogniteClient.geospatial.update_features(...)

Update features.

AsyncCogniteClient.geospatial.list_features(...)

List features.

AsyncCogniteClient.geospatial.search_features(...)

Search for features.

AsyncCogniteClient.geospatial.stream_features(...)

Stream features.

AsyncCogniteClient.geospatial.aggregate_features(...)

Aggregate filtered features.

Reference systems

AsyncCogniteClient.geospatial.get_coordinate_reference_systems(srids)

Get Coordinate Reference Systems.

AsyncCogniteClient.geospatial.list_coordinate_reference_systems([...])

List Coordinate Reference Systems.

AsyncCogniteClient.geospatial.create_coordinate_reference_systems(crs)

Create Coordinate Reference System.

Raster data

AsyncCogniteClient.geospatial.put_raster(...)

Put raster.

AsyncCogniteClient.geospatial.delete_raster(...)

Delete raster.

AsyncCogniteClient.geospatial.get_raster(...)

Get raster.

AsyncCogniteClient.geospatial.compute(output)

Compute.

Geospatial Data classes

class cognite.client.data_classes.geospatial.CoordinateReferenceSystem(srid: int, wkt: str, proj_string: str)

Bases: CoordinateReferenceSystemCore

A 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:
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], ABC

A representation of a feature in the geospatial API.

Parameters:
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: CoordinateReferenceSystemCore

A representation of a feature in the geospatial API.

Parameters:
as_write() CoordinateReferenceSystemWrite

Returns this CoordinateReferenceSystemWrite instance.

class cognite.client.data_classes.geospatial.CoordinateReferenceSystemWriteList(
resources: Sequence[T_CogniteResource],
)

Bases: CogniteResourceList[CoordinateReferenceSystemWrite]

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: FeatureCore

A 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: CogniteResource

A 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], ABC

A 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',
) FeatureList

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:

FeatureList

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,
) geopandas.GeoDataFrame

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: FeatureTypeCore

A 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], ABC

A 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: FeatureTypeCore

A 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: FeatureCore

A 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: ABC

A 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: CogniteResource

A 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: CogniteResource

The geospatial compute response.

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.GeospatialGeometryComputeFunction

Bases: GeospatialComputeFunction, ABC

A geospatial geometry compute function

class cognite.client.data_classes.geospatial.GeospatialGeometryTransformComputeFunction(
geospatial_geometry_compute_function: GeospatialComputeFunction,
srid: int,
)

Bases: GeospatialComputeFunction

A 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: GeospatialGeometryComputeFunction

A 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: object

An 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: CogniteResource

A representation of a feature type property and search spec.

class cognite.client.data_classes.geospatial.RasterMetadata(**properties: Any)

Bases: object

Raster metadata

cognite.client.data_classes.geospatial.nan_to_none(column_value: Any) Any

Convert NaN value to None.