Authentication and authorization
All HTTP endpoints served by the Geospatial API require a valid ticket from the Auth service. Feature type and feature related endpoints require the GEOSPATIAL capability (READ or WRITE). CRS related endpoints require the GEOSPATIAL_CRS capability to be enabled (READ or WRITE). Note that reading the predefined CRSs is possible with the GEOSPATIAL capability.Data sets
Feature types and Features support using data sets. Since feature types define the specification of features, you must set these access capabilities:READaccess for the feature type to do any operations (create, update, get by ids, search, and aggregate) on the corresponding features.WRITEaccess for all features of a feature type to delete the feature type.
Example
Assuming that- data set 1234 isn’t write-protected
- data set 5678 is write-protected
- feature type FT1 has data set ID 1234
- feature type FT2 has data set ID 5678
- feature type FT3 doesn’t have data set ID.
geospatial:read:1234 indicates READ capability of geospatial objects within data set ID 1234.
geospatial:read:all indicates READ capability of geospatial objects within all scopes.
dataset:owner:5678 indicates OWNER capability of data set ID 5678.
CRSs don’t support data sets.
Feature types
A CDF feature type defines a class of spatial features with a common specification. The specification defines the property names and their types and the indexes to support to fulfill performance requirements a client might have. Indexing properties come at a price when creating features, and it’s crucial to consider whether an index is necessary or not. The choice depends on the size and number of entries for a given feature type and the frequency of access to that particular property.Features
A feature is an item following the specification given by its corresponding feature type. A parallel with a class and an object is valid.Properties
Default properties
Feature types predefined properties
Feature types have predefined properties that enable close integration with the rest of the CDF. These properties are:Feature predefined properties
Features have the same predefined properties and in addition theassetIds property which has a list of internal asset ids of linked assets:
Reserved property names
The following property names are reserved for future use:- id
- metadata
- defaultGeometry
- defaultRaster
- labels
Property types
You can find the GeoJSON specification at GeoJSON and the Well-Known-Text specification at Open Geospatial Consortium.2D
The Geospatial service supports the following vector types, located in a 2-dimensional space, each as an X and a Y coordinate:3D
The Geospatial service supports the following vector types, located in a 3-dimensional space, each as an X, Y, and Z coordinate. The GeoJSON notation don’t support the following vector types:
The fact that a geometry has a Z coordinate doesn’t make it a volumetric geometry. It remains a planar 2D geometry described in a 3D space.
2D + measurement / time
The Geospatial service supports the following vector types, located in a 2-dimensional space plus an extra measure, each as an X, Y, and M coordinates. The GeoJSON notation doesn’t support the below vector types:
The M coordinate is convenient to associate a measure with a point in space. Without the M coordinate, you’d require an extra property (of array type, not supported by the service) to store the measurement. The M coordinate doesn’t require a spatial interpretation, and its unit isn’t related to the X, Y, and Z coordinates. The M coordinate remains unchanged when the geometry gets transformed.
3D + measurement / time
The Geospatial service supports the following vector types, located in a 3-dimensional space plus an extra measure, each as an X, Y, Z, and M coordinates. The GeoJSON notation doesn’t support the following vector types:Geometry collections
The Geospatial service finally supports collections of the earlier vector types. It’s a collection of heterogeneous vector types. The GeoJSON notation doesn’t support the below vector types:Simple types
In addition to spatial property types, the following versatile types are supported:More on properties
By default, the feature type properties are non-null. it’s possible to define optional properties simply by adding an optional field with true value in the property definition. In addition to this, it’s possible to add a note on a property using the description field.Searching for features
It’s possible to retrieve a feature if you know its external id. But the typical use case with geospatial data is searching for data using a geospatial filter. The following operators are currently supported:- stWithin
- stWithinProperly
- stIntersects
- stContains
- stContainsProperly
- stWithinDistance
- stIntersects3d
- stWithinDistance3d
Paginate features
The Geospatial service supports cursors to paginate through the features of a feature type. ThenextCursor property of the response returns the cursor value.
cursor field changed to the value returned in nextCursor as in the example below.
https://...cognitedata.com/api/v1/projects/.../geospatial/featuretypes/.../features/list
Spatial filter operators
-
stIntersects
This is a 2D operator.
Geometry A intersects geometry B if and only if there are points belonging to both A and B. In particular, any geometry intersects itself.
The green geometry intersects the orange geometry in each of the examples below.
-
stWithin
This is a 2D operator.
Geometry A is within geometry B if and only if all the points of A also belong to B. In particular, every geometry is within itself. In each of the examples below, the green geometry is within the orange geometry. In each of the examples below, the green geometry isn’t within the orange geometry.
-
stWithinProperly
This is a 2D operator.
Geometry A is completely within geometry B if and only if all the points of A lie in the interior of B. Geometry A is completely within geometry B if and only if A is within B and the intersection of A and the boundary of B is empty. Any geometry A isn’t completely within itself.
- stContains This is a 2D operator. The relation “contains” is an opposite relation to “within”: geometry A contains geometry B if and only if B is within A.
- stContainsProperly This is a 2D operator. The relation “contains properly” is the opposite relation to “within properly”: geometry A properly contains geometry B if and only if B is properly within A.
-
stWithinDistance
This is a 2D operator.
Geometry A is within the distance of geometry B if and only if there is a pair of points a in A and b in B and the distance between a and b is less than or equal to the given distance. The distance is specified in units defined by the coordinate reference system (CRS).
In the example below, the geometries are within distance d from each other.
- stIntersects3d This is a 3D operator. Geometry A intersects geometry B if and only if there are points belonging to both A and B. In particular, any geometry intersects itself.
- stWithinDistance3d This is a 3D operator. Geometry A is within the distance of geometry B if and only if there is a pair of points a in A and b in B and the distance between a and b is less than or equal to the given distance. The distance is specified in units defined by the coordinate reference system (CRS).
Indexes
By default, features index theirexternalId, createdTime, and lastUpdatedTime.
Several features in a given feature type impact the filtering features. Associating an index with a property allows for more efficient filtering when the property is present in the filter expression. However, this isn’t a guarantee since it will depend on the index’s selectivity, which is data-dependent.
Example of specifying an index on the point2d property:
Coordinate Reference Systems
A Coordinate Reference System (CRS) defines a 2D or 3D reference somewhere on or above/below the Earth’s surface. Coordinates are usually defined in East/North/Height order, but this can vary from one CRS to the next. Most CRSs are only valid over a limited part of the globe, so for global mapping purposes, it’s common to use GPS latitude/longitude values defined by WGS84 and encoded as the EPSG/SRID (Spatial Reference ID) number 4326.Predefined CRSs
CDF currently supports about 8500 well known CRSs, all defined by European Petroleum Survey Group (EPSG).Custom CRS
If a user needs an EPSG entry that’s currently missing, you can add it as a custom CRS. Any API user can create a custom CRS; there will be a limit on how many such definitions each customer can make. A custom CRS is defined by a reference number (a positive integer), by a wkt (Well Known Text) string, and by a projString. The projString defines the geometrical projection needed to convert coordinates in this CRS into one of the standard CRSs. The projString needs to be in the format defined by the industry-standard PROJ library (https://proj.org/). For example, the string+proj=ortho +lat_0=59.123456 +lon_0=4.7654321 +x_0=0 +y_0=0 +ellps=intl defines an orthogonal 3D CRS located at a point in the North Sea, oriented so that geographic east is the x-direction, y is north, and z points up. The ellipsoid used (International 1924) means that the lat/long values are according to that older standard, resulting in an offset (in this particular region) of about 30 m east-west from the GPS coordinate with the same numeric latitude/longitude values.
Enable CRS transformations
By default, when working with a feature type defining a geometry property with specified CRS, for example, the SRID field is set, you can’t use a different CRS when you create or update features or search or aggregate with geometry filters on that property. Change this behavior by setting the allowCrsTransformation flag to true. The API will then transform the input geometry coordinates from the input geometry CRS into the feature type property CRS. Consider the feature type extract below.https://...cognitedata.com/api/v1/projects/.../geospatial/featuretypes
https://...cognitedata.com/api/v1/projects/.../geospatial/featuretypes/.../features
https://...cognitedata.com/api/v1/projects/.../geospatial/featuretypes/.../features/search
Geometry properties without a CRS specified
Consider a feature type with a geometry propertygeomOriginal without a specified CRS, for example, the SRID field isn’t set. The different features in this feature type will have geomOriginal geometries in different CRS (EPSG:4326, EPSG:3857, EPSG:4230, etc.).
The API doesn’t allow spatial filtering on that geomOriginal property since it would require transforming all the geometries in a common CRS before the filtering can be applied. In addition to the performance implications, the choice of such a common CRS depends on the use case. Therefore, the API can’t decide which one to use.
In addition, any CRS conversion implies a potential loss of precision and possibly some distortion. You should retain geometries in their original CRS. Concretely, you will ingest the geometries twice, once in the original CRS, once in the specified common CRS of your choice.
Back to the example above with geomOriginal, we create an additional geometry property with a specified CRS, here EPSG:4326, for example, geom4326. The property complements the initial geomOriginal one, and will allow spatial filtering.
The feature type creation looks the following way.
https://...cognitedata.com/api/v1/projects/.../geospatial/featuretypes
https://...cognitedata.com/api/v1/projects/.../geospatial/featuretypes/.../features
geom4326 column can then be achieved for search/aggregation as shown here.
https://...cognitedata.com/api/v1/projects/.../geospatial/featuretypes/.../features/search
Raster data
Rasters organize data into pixels or cells and can be split into rectangular tiles. The number of horizontal and vertical pixels defines the size of a raster tile. Each pixel is identified by a row and column in a tile and represents a position. A pixel is also a placeholder for data. The data elements rest in bands, also known as channels or dimensions. Rasters can be georeferenced, where each pixel corresponds to a defined area on earth, in a defined Coordinate Reference System. An example raster image from Global Wind Atlas
- upperleftx: the upper left X coordinate of the raster.
- upperlefty: the upper left Y coordinate of the raster.
- width: the width of the raster in pixels.
- height: the height of the raster in pixels.
- scalex: the X component of the pixel width in the coordinate reference system units.
- scaley: the Y component of the pixel height in the coordinate reference system units.
- skewx: the georeference X skew.
- skewy: the georeference Y skew.
- srid: the spatial reference identifier of the raster.
- numbands: the number of bands in the raster object.
Raster properties
A CDF Geospatial feature type can have zero, one, or many raster properties.A feature type raster property must be optional and require a fixed SRID.
- embedded: the raster will be stored in the database
- file: point to a cloud storage file for the raster (currently not supported)
Ingesting raster
Due to the size (typically at least megabytes) and nature of the data (often binary), the raster data input and output are served from a different endpoint.Embedded storage
To insert raster data:-
Insert the feature without raster information.
- Push the raster RAW data.
Depending on the GDAL driver used to read GDAL input content, there is potential precision loss when ingesting the raster. For example, ASCII Gridded XYZ driver only supports a single precision floating point. When getting XYZ raster, SIGNIFICANT_DIGITS option can be used to specify the number of significant digits of the output raster.
Computation
The geospatial API provides a/compute endpoint to run arbitrary complex geospatial computations. Currently, the endpoint only supports direct geometry coordinate transformations.
The pseudo JSON structure of a /compute request looks like this:
<output-property-name-...>represents the name of an output JSON property chosen by the client making the request.<function-name>is the name of a registered function for the/computeendpoint. A function might have one or many arguments, represented as<function-argument-...>.
/compute response looks like this: