Skip to content

Identify Features

Use this endpoint to discover features at a specific location.

https://api3.geo.admin.ch/rest/services/api/MapServer/identify

WARNING

No more than 50 features can be retrieved per request.

Request Details

To interact with the identify endpoint, you need to provide specific parameters in your request. This endpoint only has query parameters that modify the behavior of the request, some are required and some are optional.

Query Parameters

ParameterDescription
geometry (required)The geometry to identify on. The geometry is specified by the geometry type. This parameter is specified as a separated list of coordinates. The simple syntax (comma-separated list of coordinates) and the complex one can be used. (ESRI syntax for geometries)
geometryType (required)The type of geometry to identify on. Supported values are: esriGeometryPoint, esriGeometryPolyline, esriGeometryPolygon, or esriGeometryEnvelope.
layers (optional)The layers to perform the identify operation on. By default, query all the layers in the GeoAdmin API. Notation: all:"comma-separated list of technical layer names".
tolerance (required)The tolerance in pixels around the specified geometry. This parameter is used to create a buffer around the geometry. Therefore, a tolerance of 0 deactivates the buffer creation.
mapExtent (required/optional)The extent of the map (minx, miny, maxx, maxy). Optional if tolerance=0. Defaults to 0,0,0,0. The mapExtent and the imageDisplay parameters are used by the server to calculate the resolution or scale.
imageDisplay (required/optional)The screen image display parameters (width, height, and dpi) of the map. The mapExtent and imageDisplay parameters are used by the server to calculate the distance on the map to search based on the tolerance in screen pixels. Optional if tolerance=0. Defaults to 0,0,0. The combination of mapExtent and imageDisplay is used to compute a resolution or scale. Some layers have scale-dependent geometries.
returnGeometry (optional)This parameter defines whether the geometry is returned or not. Defaults to true.
geometryFormat (optional)Returned geometry format. Defaults to ESRI geometry format. Supported values are: esrijson or geojson.
offset (optional)Offset for the first record (if more than 50 records).
sr (optional)The spatial reference. Supported values: 21781 (LV03), 2056 (LV95), 4326 (WGS84), and 3857 (Web Pseudo-Mercator). Defaults to 21781.
lang (optional)The language. Supported values: de, fr, it, rm, en. Defaults to de.
layerDefs (optional)Filter features with an expression. Syntax: { "<layerId>" : "<layerDef1>" } where <layerId> must correspond to the layer specified in layers. See below for more details.
callback (optional)The name of the callback function.

Tolerance, mapExtent and imageDisplay

The values of imageDisplay and mapExtent must be set for a tolerance > 0. This is because we need them to map the tolerance from pixels to meters. For a tolerance=0, however, we would only set imageDisplay and mapExtent for specific cases. One such case might be a scale dependant model that you display as points at smaller scales and as polygons at larger scales.

The following table summarize the various combinations:

ToleranceimageDisplay=0,0,0 mapExtent=0,0,0,0imageDisplay=1,1,1 mapExtent=1,1,1,1
tolerance=0No buffer & no scaleNo buffer, but scale
tolerance>0ForbiddenBuffer & scale

Filtering

To filter features on a set of attributes, we can use the layerDefs parameter on "queryable" layers.

So-called "queryable" layers are:

txt
ch.astra.unfaelle-personenschaeden_alle
ch.astra.unfaelle-personenschaeden_fahrraeder
ch.astra.unfaelle-personenschaeden_fussgaenger
ch.astra.unfaelle-personenschaeden_getoetete
ch.astra.unfaelle-personenschaeden_motorraeder
ch.bafu.landesforstinventar-vegetationshoehenmodell
ch.bafu.wrz-wildruhezonen_portal
ch.bfe.solarenergie-eignung-daecher
ch.bfe.solarenergie-eignung-fassaden
ch.swisstopo.amtliches-gebaeudeadressverzeichnis
ch.swisstopo.amtliches-strassenverzeichnis

Regarding the format of the layerDefs parameter:

  • Use a JSON-like format: {"<layername>":"<filter_expression>"}.

  • The <filter_expression is defined in the form <attribute><operator><value> where

    • <attribute> must be one of the queryable attributes listed by the layer attribute endpoint.
    • <operator> must be one of the following options:
    OperatorOperatorsExamples
    varchar=, +=, like, ilike, not like, not ilike, is null, is not nulltoto = '3455 Kloten', toto ilike '%SH%', toto is null, toto ilike 'SH%'
    number=, <, >, >=, <=, !=tutu >= 2.4, tutu < 5
    booleanis (true/false), is not (true/false)tata is not false
    • <value> must correspond to the type of the queryable attribute.

In an example:

Request
Response
sh
curl "https://api3.geo.admin.ch/rest/services/all/MapServer/identify?"\
"geometryType=esriGeometryEnvelope&"\
"geometry=2548945.5,1147956,2549402,1148103.5&"\
"geometryFormat=geojson&"\
"imageDisplay=1367,949,96&"\
"lang=en&"\
"layers=all:ch.swisstopo.amtliches-strassenverzeichnis&"\
"mapExtent=2318250,952750,3001750,1427250&"\
"returnGeometry=false&"\
"sr=2056&"\
"tolerance=5&"\
"layerDefs={\"ch.swisstopo.amtliches-strassenverzeichnis\":\"stn_label+ilike+%27%Corniche%%27\"}"

Correct Encoding

It's important that the parameters are correctly serialized and url-encoded.

To encode the layerDefs parameter in your URL using the right URL escape codes (%xx), you may want to make use of Python's urllib.parse.quote():

python
import json
import urllib.parse

params = {
  "ch.swisstopo.amtliches-strassenverzeichnis": "zip_label = '8302 Kloten'"
}
print(f'&layerDefs={urllib.parse.quote(json.dumps(params))}')
## &layerDefs=%7B%22ch.swisstopo.amtliches-strassenverzeichnis%22%3A%20%22zip_label%20%3D%20%278302%20Kloten%27%22%7D

Examples

Identify all the features belonging to ch.bafu.nabelstationen using a tolerance of 5 pixels around a point:

Request
Response
sh
curl "https://api3.geo.admin.ch/rest/services/all/MapServer/identify?"\
"geometry=678250,213000&"\
"geometryFormat=geojson&"\
"geometryType=esriGeometryPoint&"\
"imageDisplay=1391,1070,96&"\
"lang=fr&"\
"layers=all:ch.bafu.nabelstationen&"\
"mapExtent=312250,-77500,1007750,457500&"\
"returnGeometry=true&"\
"tolerance=5"

Identify all the features belonging to ch.bfs.arealstatistik intersecting an envelope (or bounding box):

Request
Response
sh
curl "https://api3.geo.admin.ch/rest/services/api/MapServer/identify?"\
"geometryType=esriGeometryEnvelope&"\
"geometry=548945.5,147956,549402,148103.5&"\
"imageDisplay=500,600,96&"\
"mapExtent=548945.5,147956,549402,148103.5&"\
"tolerance=1&"\
"layers=all:ch.bfs.arealstatistik"

Identify all the features belonging to ch.bafu.bundesinventare-bln a polyline:

Request
Response
sh
curl "https://api3.geo.admin.ch/rest/services/api/MapServer/identify?"\
"geometry={\"paths\":[[[675000,245000],[660000,260000],[620000,250000]]]}&"\
"geometryType=esriGeometryPolyline&"\
"imageDisplay=500,600,96&"\
"mapExtent=548945.5,147956,549402,148103.5&"\
"tolerance=5&"\
"layers=all:ch.bafu.bundesinventare-bln"

Identify all the features belonging to ch.bafu.bundesinventare-bln intersecting a polygon:

Request
Response
sh
curl "https://api3.geo.admin.ch/rest/services/api/MapServer/identify?"\
"geometry={\"rings\":[[[675000,245000],[670000,255000],[680000,260000],[690000,255000],[685000,240000],[675000,245000]]]}&"\
"geometryType=esriGeometryPolygon&"\
"imageDisplay=500,600,96&"\
"mapExtent=548945.5,147956,549402,148103.5&"\
"tolerance=5&"\
"layers=all:ch.bafu.bundesinventare-bln"

Same request for ch.bfs.arealstatistik as above but returned geometry format is GeoJSON:

Request
Response
sh
curl "https://api3.geo.admin.ch/rest/services/api/MapServer/identify?"\
"geometryType=esriGeometryEnvelope&"\
"geometry=548945.5,147956,549402,148103.5&"\
"imageDisplay=500,600,96&"\
"mapExtent=548945.5,147956,549402,148103.5&"\
"tolerance=1&"\
"layers=all:ch.bfs.arealstatistik&"\
"geometryFormat=geojson"

Same request for ch.bfs.arealstatistik as above but geometry is not returned:

Request
Response
sh
curl "https://api3.geo.admin.ch/rest/services/api/MapServer/identify?"\
"geometryType=esriGeometryEnvelope&"\
"geometry=548945.5,147956,549402,148103.5&"\
"imageDisplay=500,600,96&"\
"mapExtent=548945.5,147956,549402,148103.5&"\
"tolerance=1&"\
"layers=all:ch.bfs.arealstatistik&"\
"returnGeometry=false"

Examples: Reverse Geocoding

The identify endpoint can be used for reverse geocoding operations.

Perform an identify request to find the districts intersecting a given envelope geometry (no buffer):

Request
Response
sh
curl "https://api3.geo.admin.ch/rest/services/api/MapServer/identify?"\
"geometryType=esriGeometryEnvelope&"\
"geometry=548945.5,147956,549402,148103.5&"\
"imageDisplay=0,0,0&"\
"mapExtent=0,0,0,0&"\
"tolerance=0&"\
"layers=all:ch.swisstopo.swissboundaries3d-bezirk-flaeche.fill&"\
"returnGeometry=false"

Perform an identify request to find the municipal boundaries and ZIP (PLZ or NPA) intersecting with a point (no buffer):

Request
Response
sh
curl "https://api3.geo.admin.ch/rest/services/api/MapServer/identify?"\
"geometryType=esriGeometryPoint&"\
"geometry=548945.5,147956&"\
"imageDisplay=0,0,0&"\
"mapExtent=0,0,0,0&"\
"tolerance=0&"\
"layers=all:ch.swisstopo.swissboundaries3d-gemeinde-flaeche.fill,ch.swisstopo-vd.ortschaftenverzeichnis_plz&"\
"returnGeometry=false"

Reverse geocoding an address with a point (no buffer):

Request
Response
sh
curl "https://api3.geo.admin.ch/rest/services/api/MapServer/identify?"\
"geometryType=esriGeometryPoint&"\
"geometry=548945.5,147956&"\
"imageDisplay=0,0,0&"\
"mapExtent=0,0,0,0&"\
"tolerance=0&"\
"layers=all:ch.swisstopo.swissboundaries3d-gemeinde-flaeche.fill,ch.swisstopo-vd.ortschaftenverzeichnis_plz&"\
"returnGeometry=false"

Examples: Search Radius

To search within a specified radius at a given location:

  1. Specify the location with geometry and set the geometryType to esriGeometryPoint.

  2. Set mapExtent, imageDisplay and tolerance such that you get the desired search radius in meters according to this relation:

searchRadius = max(mapExtent.maxx / imageDisplay.width, mapExtent.maxy / imageDisplay.height) * tolerance toleranceInPx

For example, if you want a search radius of 5 meters, you could set tolerance=5 for a mapExtent=0,0,100,100 and a imageDisplay=100,100,100:

searchRadius = max(mapExtent.maxx / imageDisplay.width, mapExtent.maxy / imageDisplay.height) * tolerance toleranceInPx
             = max(100 / 100, 100 / 100) * 5
             = 5

So, to perform an identify request with a search radius of 5 meters around a given point, you would set:

Request
Response
sh
curl "https://api3.geo.admin.ch/rest/services/api/MapServer/identify?"\
"mapExtent=0,0,100,100&"\
"imageDisplay=100,100,100&"\
"tolerance=5&"\
"geometryType=esriGeometryPoint&"\
"geometry=548945,147956"

Download as INTERLIS

For a limited set of "ÖREB" layers, features can be retrieved in the INTERLIS format (XML) with geometryFormat=interlis. "ÖREB" is the German accronym for the Cadastre of public-law restrictions on landownership.

WARNING

The INTERLIS format is designed for specialized applications and may not be suitable for general use. For most users, we recommend using one of the following formats instead:

  • geometryFormat=geojson
  • geometryFormat=esrijson

The following layers are based on the ÖREB model V2_0 and offer features in the INTERLIS format:

  • Layers with data:

    txt
    ch.astra.baulinien-nationalstrassen_v2_0.oereb
    ch.bazl.projektierungszonen-flughafenanlagen_v2_0.oereb
    ch.bazl.sicherheitszonenplan_v2_0.oereb
    ch.vbs.kataster-belasteter-standorte-militaer_v2_0.oereb
    ch.bazl.kataster-belasteter-standorte-zivilflugplaetze_v2_0.oereb
    ch.bav.kataster-belasteter-standorte-oev_v2_0.oereb
  • Layers without data:

    txt
    ch.astra.projektierungszonen-nationalstrassen_v2_0.oereb
    ch.bav.projektierungszonen-eisenbahnanlagen_v2_0.oereb
    ch.bav.baulinien-eisenbahnanlagen_v2_0.oereb
    ch.bazl.baulinien-flughafenanlagen_v2_0.oereb
    ch.bfe.projektierungszonen-starkstromanlagen_v2_0.oereb
    ch.bfe.baulinien-starkstromanlagen_v2_0.oereb

Example ÖREB Queries

Look for all the features of ch.bazl.projektierungszonen-flughafenanlagen_v2_0.oereb using a point:

https://api3.geo.admin.ch/rest/services/api/MapServer/identify?geometry=2682414.312,1257059.381&geometryType=esriGeometryPoint&layers=all:ch.bazl.projektierungszonen-flughafenanlagen_v2_0.oereb&mapExtent=2480000,1070000,2840000,1310000&imageDisplay=3600,2400,96&tolerance=0&geometryFormat=interlis&sr=2056

Look for all the features of ch.bav.kataster-belasteter-standorte-oev_v2_0.oereb using a polygon:

https://api3.geo.admin.ch/rest/services/api/MapServer/identify?geometry={"rings":[[[2675000,1245000],[2670000,1255000],[2680000,1260000],[2690000,1255000],[2685000,1240000],[2675000,1245000]]]}&geometryType=esriGeometryPolygon&layers=all:ch.bav.kataster-belasteter-standorte-oev_v2_0.oereb&mapExtent=2480000,1070000,2840000,1310000&imageDisplay=3600,2400,96&tolerance=0&geometryFormat=interlis&sr=2056

Look for all the features of ch.bazl.sicherheitszonenplan_v2_0.oereb using a bounding box (envelope):

https://api3.geo.admin.ch/rest/services/api/MapServer/identify?geometry=2575000,1109000,2610000,1127000&geometryType=esriGeometryEnvelope&layers=all:ch.bazl.sicherheitszonenplan_v2_0.oereb&mapExtent=2480000,1070000,2840000,1310000&imageDisplay=3600,2400,96&tolerance=0&geometryFormat=interlis&sr=2056

Look for all the features of ch.astra.baulinien-nationalstrassen_v2_0.oereb using a bounding box (envelope):

https://api3.geo.admin.ch/rest/services/api/MapServer/identify?geometry=2599000,1200000,2604000,1203000&geometryType=esriGeometryEnvelope&layers=all:ch.astra.baulinien-nationalstrassen_v2_0.oereb&mapExtent=2480000,1070000,2840000,1310000&imageDisplay=3600,2400,96&tolerance=0&geometryFormat=interlis&sr=2056