This document is licensed under
Creative Commons Attribution 4.0 International Public License
This document is part of the Nederlandse API Strategie.
The Nederlandse API Strategie consists of a set of distinct documents.
Status | Description & Link |
---|---|
Informative | Inleiding NL API Strategie |
Informative | Architectuur NL API Strategie |
Informative | Gebruikerswensen NL API Strategie |
Normative | API Design Rules (ADR v2.0) |
Normative | Open API Specification (OAS 3.0) |
Normative | NL GOV OAuth profiel |
Normative | Digikoppeling REST API koppelvlak specificatie |
Normative module | GEO module v1.0 |
Before reading this document it is advised to gain knowledge of the informative documents, in particular the Architecture.
This document describes the Geospatial module, containing rules for geospatial content and functions in APIs.
This is a draft that could be altered, removed or replaced by other documents. It is not a recommendation approved by TO.
This document provides rules for publishing geospatial data using Web APIs. Spatial data is
data that describes anything with spatial extent (i.e. size, shape or position). Spatial data is also known as location information. [sdw-bp]
Geospatial data is more specific in that it is explicitly located relative to the Earth.
Geospatial data is 'special' data in the sense that it typically indicates the location of things using geometry. This geometry allows geospatial functions such as 'find only the things located within this area' but also requires specific ways of handling. There are international regulations and standards for geospatial data that need to be taken into account in certain cases.
The Geospatial Module provides rules for the structuring of geospatial payloads and for functions in APIs to handle geospatial data.
Providing requested resources is the essence of any API. This also applies to REST APIs that handle geospatial data. There are, however, some specific aspects when dealing with geospatial data in REST APIs. The most important aspects are described in this chapter:
When requesting information, for example about cadastral parcels, users do not necessarily require the geometry, even if they used a spatial filter. A name or parcel ID may be sufficient.
[rfc7946] describes the GeoJSON format, including a convention for describing 2D geometric objects in CRS84 (OGC:CRS84). In the Geospatial module of the API strategy we adopt the GeoJSON conventions for describing geometry objects. The convention is extended to allow alternative projections. The GeoJSON conventions and extensions described in this module apply to both geometry passed in input parameters and responses.
Example of embedding WKT in a JSON object using the following definition for a JSON object:
building:
type: object
required:
- geometry
properties:
geometry:
type: string
format: wkt
Sample response:
{
"building": {
"geometry": "POLYGON Z((194174.445 465873.676 0, 194174.452 465872.291 0, 194158.154 465872.213 0, 194158.226 465856.695 0, 194223.89 465856.969 0, 194223.821 465872.48 0, 194207.529 465872.415 0, 194207.505 465882.528 0, 194207.498 465883.902 0, 194223.799 465883.967 0, 194223.732 465899.48 0, 194216.55 465899.45 0, 194215.15 465899.445 0, 194213.85 465899.439 0, 194158.068 465899.211 0, 194158.148 465883.685 0, 194174.42 465883.767 0, 194174.445 465873.676 0))"
}
}
Example of embedding WKB in a JSON object using the following definition for a JSON object:
building:
type: object
required:
- geometry
properties:
geometry:
type: string
format: wkb
Sample response:
{
"building": {
"geometry": "01030000A0F71C00000100000012000000F6285C8FF3B30741105839B4466F1C4100000000000000000E2DB29DF3B307416DE7FB29416F1C4100000000000000001D5A643B71B3074108AC1CDA406F1C4100000000000000008716D9CE71B307417B14AEC7026F1C410000000000000000EC51B81E7FB50741378941E0036F1C410000000000000000B07268917EB50741B81E85EB416F1C4100000000000000001D5A643BFCB407418FC2F5A8416F1C410000000000000000A4703D0AFCB407413108AC1C6A6F1C4100000000000000008B6CE7FBFBB4074154E3A59B6F6F1C410000000000000000AC1C5A647EB507417D3F35DE6F6F1C410000000000000000E5D022DB7DB50741B81E85EBAD6F1C4100000000000000006666666644B50741CDCCCCCCAD6F1C4100000000000000003333333339B507417B14AEC7AD6F1C410000000000000000CDCCCCCC2EB507414C3789C1AD6F1C4100000000000000008195438B70B307414E6210D8AC6F1C410000000000000000BE9F1A2F71B30741D7A370BD6E6F1C410000000000000000C3F5285CF3B30741B07268116F6F1C410000000000000000F6285C8FF3B30741105839B4466F1C410000000000000000"
}
}
A simple spatial filter can be supplied as a bounding box. This is a common way of filtering spatial data and can be supplied as a parameter. We adopt the OGC API Features [ogcapi-features-1] bounding box parameter:
/geo/bbox-query-parameter: Supply a simple spatial filter as a bounding box parameter
bbox
query parameter in conformance to the standard.
The default spatial operator intersects
is used to determine which resources are returned.
Due to possible performance issue, especially when a combination of filters is used, a provider may decide to limit the size of the bounding box or the number of results. It is also up to the provider to decide if an error is returned in such cases. The provider shall clearly document this behavior.
The provider shall be able to provide resources that do not have a geometry property and are related to resources that match the bounding box filter.
An error shall be given if the provided coordinates are outside the specified coordinate reference system.
bbox
query parameter and using CRS Negotiation.
/geo/geometric-context: Place results of a global spatial query in the relevant geometric context
/api/v1/_search
, results should be placed in the relevant geometric context, because results from different collections, i.e. different sets of resources of the same type, are retrieved. Express the name of the collection to which the results belong in the singular form using the property type
. For example:
type
property for each member.In case a REST API shall comply to the OGC API Features specification for creating, updating and deleting a resource, the following applies.
/geo/geojson-request: Support GeoJSON in geospatial API requests
application/geo+json
in the Content-Type
header.201
(Created) is returned.Location
header with the URI of the newly added resource.
In case a REST API does not have to comply to the OGC API Features specification, e.g. for usage in administrative applications, the REST API shall use the JSON data format. If a resource contains geometry, that geometry shall be embedded as a GeoJSON Geometry
object within the resource. The media type application/json
must be supported. This may also apply to other media types application/*+json
, however this depends on the media type specification. If the media type specification prescribes that resource information must be embedded in a JSON structure defined in the media specification, then the media type should not be supported while it is impossible to comply to that specification with the method described below. The media type application/geo+json
should not be supported while the resource does not comply to the GeoJSON specification, i.e. the request resource does not embed a feature or feature collection.
A template for the definition of the schemas for the GeoJSON Geometry
object in the requests in OpenAPI definitions is available: geometryGeoJSON.yaml.
In case a collection of resources is embedded in the request resource, the name of the array containing the resources should be the plural of the resource name.
/geo/embed-geojson-geometry-request: Embed GeoJSON Geometry
object as part of the JSON resource in API requests
application/json
) request contains a geometry, represent it in the same way as the Geometry
object of GeoJSON.
Geometry
object type using the HTTP POST method with request media type application/json
in the Content-Type
header.201
(Created) is returned.Location
header with the URI of the newly added resource.
In case a REST API shall comply to the OGC API Features specification, e.g. for usage in GIS applications, the following applies.
/geo/geojson-response: Support GeoJSON in geospatial API responsess
naam
) are passed in the properties object. Depending on the implemented filter capabilities the properties object may contain all or a selection of the resources' properties.application/geo+json
in the Accept
header.Content-Type
header contains application/geo+json
application/geo+json
in the Accept
header.Content-Type
header contains application/geo+json
application/geo+json
or application/json
in the Accept
header.Content-Type
header contains application/json
application/geo+json
or application/json
in the Accept
header.Content-Type
header contains application/json
In case a REST API does not have to comply to the OGC API Features specification, e.g. for usage in administrative applications, the REST API shall use the JSON data format. If resources contain geometry, the geometry shall be returned as a GeoJSON Geometry
object embedded in the resource. The media type application/json
must be supported. This may also apply to other media types application/*+json
, however this depends on the media type specification. If the media type specification prescribes that resource information must be embedded in a JSON structure defined in the media type specification, then the media type should not be supported while it is impossible to comply to that specification with the method described below. The media type application/geo+json
should not be supported while the resource does not comply to the GeoJSON specification, i.e. the response does not return a feature or feature collection.
A template for the definition of the schemas for the GeoJSON Geometry
object in the responses in OpenAPI definitions is available: geometryGeoJSON.yaml.
In case a collection of resources is returned, the name of the array containing the resources should be the plural of the resource name.
/geo/embed-geojson-geometry-response: Embed GeoJSON Geometry
object as part of the JSON resource in API responses
application/json
) response contains a geometry, represent it in the same way as the Geometry
object of GeoJSON.
The resource and resource collection may be [HAL] resources and therefore may contain a _links
object. The _links
object should contain a self link and in case of a collection also navigation links (e.g. first, next prev, last). In such cases the application/hal+json
media type may be used.
Geometry
object type: Point
, MultiPoint
, LineString
, MultiLineString
, Polygon
or MultiPolygon
and with response media type application/json
in the Accept
header.Content-Type
header contains application/json
Geometry
objects mentioned above and contains:
type
containing the name of one of the GeoJSON Geometry
object types mentioned above, andcoordinates
containing an array with the coordinates. Depending on the type of geometry object, the content of the array differs.Geometry
object type: Point
, MultiPoint
, LineString
, MultiLineString
, Polygon
or MultiPolygon
and with response media type application/json
in the Accept
header.Content-Type
header contains application/json
Geometry
objects mentioned above and contains:
type
containing the name of one of the GeoJSON Geometry
object types mentioned above, andcoordinates
containing an array with the coordinates. Depending on the type of geometry object, the content of the array differs.Geometry
object type: GeometryCollection
and with response media type application/json
in the Accept
header.Content-Type
header contains application/json
Geometry
object mentioned above and contains:
type
containing the name of the GeoJSON Geometry
object type: GeometryCollection
, andgeometries
containing an array of GeoJSON Geometry
objects.Geometry
object type: GeometryCollection
and with response media type application/json
in the Accept
header.Content-Type
header contains application/json
Geometry
object mentioned above and contains:
type
containing the name of the GeoJSON Geometry
object type: GeometryCollection
, andgeometries
containing an array of GeoJSON Geometry
objects.A Coordinate Reference System (CRS) or Spatial Reference System (SRS) is a framework to measure locations on the earth surface as coordinates. Geometries consist of coordinates. To be able to measure the geometry's coordinates on the earth surface a CRS is required in conjunction with the coordinates.
CRSs are uniquely identified by means of a Spatial Reference System Identifier (SRID). SRIDs may refer to different standards, for example EPSG Geodetic Parameter Dataset or Open Geospatial Consortium (OGC).
CRSs may be grouped into ensemble CRSs, e.g. ETRS89 (EPSG:4258). The CRSs that are part of an ensemble CRS are called ensemble member CRSs or member CRSs that realize a ensemble CRS, e.g ETRF2000 (EPSG:9067) is a member of and realizes the ETRS89 (EPSG:4258) ensemble. When exchanging geometry an ensemble member CRS shall be used instead of an ensemble CRS when known and if accurate data is required. When transforming geometry from one CRS to another, use an ensemble member CRS (instead of an ensemble CRS) as input and output of coordinate transformation, when known and if accurate data is required.
For a detailed description of CRSs see [hr-crs].
A client shall be able to determine a list of CRSs supported by an API.
/geo/crs-list: Provide a list of all CRSs that are supported by the API
If a REST API shall comply to the OGC API Features specification then the API must provide an endpoint to determine a list of supported CRSs.
If a REST API does not have to comply to the OGC API Features specification, e.g. when the API is used for administrative purposes, then the API shall also provide an endpoint to determine the supported CRSs.
According to OGC API Features - part 1 - 7.13. Feature collections an OGC API Features API shall provide a GET operation on the /collections
endpoint which returns a collections object.
OGC API Features - part 2 - Coordinate Reference Systems by Reference [ogcapi-features-2] describes how to support different CRSs in your geospatial API. According to OGC API Features - part 2 - 6.2 Discovery and in particular Global list of CRS identifiers, a collections object provided by the API's /collections
endpoint may contain a global list of supported CRSs by means of the crs
property. This global CRS list applies to all feature collections delivered by the API, unless otherwise stated at a feature collection.
Each feature collection mentioned within the collections
list may also contain a crs
property if the set of supported CRSs differs from the global CRS list.
If a feature collection supports exactly the same CRSs as mentioned in the global CRS list, then the crs
property may be omitted.
If a feature collection supports additional CRSs compared to the global CRS list in the collections object, then a reference to the global CRS list #/crs
may be added in the feature collection object and the URIs of the additional CRSs are added to the CRS list in the crs
property of the feature collection.
If a feature collection supports a different set of CRSs than the set defined in the global CRS list, then a reference to the global CRS list is omitted and only the URIs of the supported CRSs are added to the CRS list in the crs
property of the feature collection.
For clients, it may be helpful to know the CRS identifier that may be used to retrieve features from that collection without the need to apply a CRS transformation. If all features in a feature collection are stored using a particular CRS, the property storageCRS
shall be used to specify this CRS, in accordance with OGC API Features - part 2 - 6.2.2 Storage CRS. The value of this property shall be one of the CRSs supported by the API and advertised in the CRS list as stated in requirement 4 of OGC API Features - part 2 - 6.2.2 Storage CRS. If relevant, the epoch should also be specified, using the storageCRSCoordinateEpoch
property. For an explanation of the use of epochs with CRS, see the CRS Guidelines [hr-crs].
If the REST API shall comply to the OGC API Features specification:
/collections
endpoint of the API.collections
object with the crs
property.If the REST API does not have to comply to the OGC API Features specification:
/crss
endpoint of the API.crs
property.In both cases, verify the following based on the response:
crs
property contains an array with CRS references in the form of URIs.epsg:CommonMetadata
element (xmlns:epsg="urn:x-ogp:spec:schema-xsd:EPSG:1.0:dataset
)./geo/storage-crs: Make known in which CRS the geospatial data is stored by specifying the property storageCrs
in the collection object
/collections
endpoint of the API.storageCRS
property.storageCRS
property is one of the URIs from the list of supported CRSs.The default CRS for GeoJSON and for OGC API Features is CRS84 (OGC:CRS84), this CRS uses the WGS 84 datum with an ellipsoidal coordinate system in the order longitude-latitude. This refers to an ensemble of global CRSs that can be applied world-wide. For accurate applications the use of the CRS84 ensemble is not suitable. For more information about coordinate reference systems, read the Geonovum guidelines on CRS [hr-crs].
/geo/default-crs: Use CRS84 as the default coordinate reference system (CRS) in line with OGC API Features Requirement 10
Since most client-side mapping libraries use WGS 84 longitude-latitude (CRS84), the W3C/OGC Spatial Data on the Web working group recommends to use this as the default coordinate reference system. The API strategy caters for this supporting not only ETRS89 and RD, but also CRS84.
The *default* CRS, i.e. the CRS which is assumed when not specified by either the API or the client, is CRS84, in line with GeoJSON and OGC API Features.
Content-Crs
header with the URI for CRS84 or CRS84h.
/geo/preferred-crs: Use ETRS89 and/or RD when required
Content-Crs
header with the URI for the requested CRS.The guiding principles for CRS support:
5.96237626, 52.25502345
). The longitude and latitude are decimal numbers. The number of decimals in the fractional part may vary depending on the required accuracy. For an accuracy of 1 mm, 8 decimals in the fractional part are sufficient. See Nauwkeurigheid van coördinaten in [hr-crs].195427.520, 311611.840
). The X and Y coordinates are decimal numbers. The number of decimals in the fractional part may vary depending on the required accuracy. For an accuracy of 1 mm, 3 decimal places in the fractional part are sufficient. See Nauwkeurigheid van coördinaten in [hr-crs]./geo/ensemble-member-crs: The ensemble member should be one of the CRSs supported by the API
/collections
endpoint.collections
object with the crs
property.crs
property contains an array with CRS references in the form of URIs.crs
property contains a URL for a ensemble CRS like ETRS89 (EPSG:4258), it also contains a URL for a ensemble member CRS like ETRF2000 (EPSG:9067)./geo/bbox-crs-query-parameter: Support passing the coordinate reference system (CRS) of the bounding box in the request as a query parameter
Support the OGC API Features part 2 bbox-crs
parameter in conformance to the standard.
If a bounding box is sent to the server without these parameters, the default CRS, CRS84, is assumed as specified in /geo/default-crs.
If an invalid value, i.e. a CRS which is not in the list of supported CRSs, is given for one of these parameters, the server responds with an HTTP status code 400
.
bbox
parameter AND the bbox-crs
parameter.Content-Crs
HTTP header with the URI of the requested CRS identifier./geo/filter-crs-query-parameter: Support passing the coordinate reference system (CRS) of the geospatial filter in the request as a query parameter
Support the OGC API Features part 3 filter-crs
parameter in conformance to the standard.
If a geospatial filter is sent to the server without these parameters, the default CRS, CRS84, is assumed as specified in /geo/default-crs.
If an invalid value, i.e. a CRS which is not in the list of supported CRSs, is given for one of these parameters, the server responds with an HTTP status code 400
.
filter-crs
parameter.Content-Crs
HTTP header with the URI of the requested CRS identifier.In an API that supports the creation and/or updating of items, POST, PUT or PATCH requests with geospatial content in the body may be sent by a client to the server. In that case, it is necessary to indicate the CRS used, unless CRS84 (OGC:CRS84), the default CRS, is used.
/geo/content-crs-request-header: When HTTP POST, PUT and/or PATCH requests are supported, pass the coordinate reference system (CRS) of geometry in the request body as a header
Support the OGC API Features part 4 Content-Crs
header in conformance to the standard.
Alternatively, if the feature representation supports expressing CRS information for each feature / geometry, the information can also be included in the feature representation. If no CRS is asserted, the default CRS, CRS84, is assumed, as stated in /geo/default-crs.
Content-Crs
header with the value of the CRS identifier for the spatial data in the body.201
in case a new item was created, or with status code 200
./geo/crs-query-parameter: Support passing the desired coordinate reference system (CRS) of the geometry in the response as a query parameter
crs
parameter in conformance to the standard.
crs
parameter.200
, and includes a Content-Crs
http header with the value of the requested CRS identifier./geo/content-crs-response-header: Assert the coordinate reference system (CRS) used in the response using a header
Content-Crs
header in conformance to the standard.
Content-Crs
header with the URI of the requested CRS identifier if explicitly requested, or with the value http://www.opengis.net/def/crs/OGC/1.3/CRS84
if no CRS was explicitly requested.The API should be able to handle the following scenarios based on the rules stated above:
Scenario | Explanation |
---|---|
No geometry in request, no geometry in response | No CRS negotiation necessary |
No geometry in request, geometry in response | The client can request a specific CRS for the geometries in the response using the crs parameter. The server indicates the geometry CRS in the response using the Content-Crs header. |
Geometry in request body, no geometry in response | The client indicates the CRS of the geometry in the request body using the Content-Crs header. |
Geometry in request body, geometry in response | The client indicates the CRS of the geometry in the request body using the Content-Crs header, and can request a specific CRS for the geometries in the response using the crs parameter. The server indicates the geometry CRS in the response using the Content-Crs header. |
Geometry filter in request, no geometry in response | The client indicates the CRS of the geometry filter in the request using the bbox-crs parameter if a bounding box is used to filter geospatially, or the filter-crs parameter if another way of geospatial filtering is used. |
Geometry filter in request, geometry in response | The client indicates the CRS of the geometry filter in the request using bbox-crs or filter-crs as in the previous scenario, and requests a specific CRS for the geometries in the response using the crs parameter. The server indicates the geometry CRS in response using the Content-Crs header. |
Below is a list of the most commonly used CRSs in the Netherlands:
Name | Code | Type | Dimension | Scope | URI |
---|---|---|---|---|---|
Amersfoort / RD New | 28992 | easting, northing (x, y) | 2D | Dutch | https://www.opengis.net/def/crs/EPSG/9.9.1/28992 |
Amersfoort / RD New + NAP height | 7415 | easting, northing, height (x, y, h) | 3D | Dutch | https://www.opengis.net/def/crs/EPSG/9.9.1/7415 |
ETRS89 | 4258 | latitude, longitude (φ, λ) | 2D | European | https://www.opengis.net/def/crs/EPSG/9.9.1/4258 |
ETRS89 | 4937 | latitude, longitude, height (φ, λ, h) | 3D | European | https://www.opengis.net/def/crs/EPSG/9.9.1/4937 |
ETRF2000 | 7931 | latitude, longitude, height (φ, λ, h) | 3D | European | https://www.opengis.net/def/crs/EPSG/9.9.1/7931 |
ETRF2000 | 9067 | latitude, longitude (φ, λ) | 2D | European | https://www.opengis.net/def/crs/EPSG/9.9.1/9067 |
ITRF2014 | 7912 | latitude, longitude, height (φ, λ, h) | 3D | Global | https://www.opengis.net/def/crs/EPSG/9.9.1/7912 |
ITRF2014 | 9000 | latitude, longitude (φ, λ) | 2D | Global | https://www.opengis.net/def/crs/EPSG/9.9.1/9000 |
WGS 84 longitude-latitude | CRS84 | longitude, latitude (λ, φ) | 2D | Global | https://www.opengis.net/def/crs/OGC/1.3/CRS84 |
WGS 84 longitude-latitude-height | CRS84h | longitude, latitude, height (λ, φ, h) | 3D | Global | https://www.opengis.net/def/crs/OGC/0/CRS84h |
WGS 84 / Pseudo-Mercator | 3857 | easting, northing (x, y) | 2D | Global | https://www.opengis.net/def/crs/EPSG/9.9.1/3857 |
For a more extensive overview of CRSs see: https://docs.geostandaarden.nl/crs/crs/#bijlage-a-crs-overzicht-tabel. Note that the URI of each CRS contains a version number and that new versions may be released in future. Before using a URI verify if newer versions are available and use the latest version.
If the requested CRS is not the same as the storage CRS, a coordinate transformation is needed. Performance is increased when the dataset is transformed in multiple CRSs and stored in advance, and not transformed at the moment the request has arrived. In case of a transformation between RD and ETRS89, it is required that this transformation uses the latest version of the procedure of RDNAPTRANS™.
INSPIRE is a European directive that forces data providers of geospatial datasets that belong to one of the 34 INSPIRE themes to publish the metadata, a viewservice and a download service. These services can also be APIs.
For the OGC-API Features, an endorsed good practice has been described in a document that proposes a technical approach for implementing the requirements set out in the INSPIRE Implementing Rules for Network Services [IRs for NS] based on the newly adopted OGC API - Features standard.
The extra requirements stated in this document concern:
These requirements should be met when an API serves features for an INSPIRE dataset.