.. raw:: html .. _rest_services: API REST Services ================= Most services are implementing or are heavily inspired by `ESRI GeoServices REST Specification `_ or by the `Open Geospatial Consortium (OGC) `_. .. _metadata_description: Layers Metadata --------------- This service provides metadata for all the available layers in the GeoAdmin API. URL *** :: https://api3.geo.admin.ch/rest/services/api/MapServer Input Parameters **************** RESTFul interface is available. +-----------------------------------+-------------------------------------------------------------------------------------------+ | Parameters | Description | +===================================+===========================================================================================+ | **searchText (optional)** | The text to search for in the layer description. | +-----------------------------------+-------------------------------------------------------------------------------------------+ | **lang (optional)** | The language. Supported values: de, fr, it , rm, en. Defaults to "de". | +-----------------------------------+-------------------------------------------------------------------------------------------+ | **sr (optional)** | The spatial reference. Supported values: 21781 (LV03), 2056 (LV95). Defaults to "21781". | +-----------------------------------+-------------------------------------------------------------------------------------------+ | **callback (optional)** | The name of the callback function. | +-----------------------------------+-------------------------------------------------------------------------------------------+ Response syntax *************** Here is an example of response. .. code-block:: javascript { "layers": [ { "name": "Temperature monitoring stations", "fullName": "Water temperature monitoring stations", "idGeoCat": "4f10c35a-8fac-4000-ab6d-7a294284059a", "layerBodId": "ch.bafu.hydrologie-wassertemperaturmessstationen", "attributes": { "wmsUrlResource": "http://wms.geo.admin.ch/?REQUEST=GetCapabilities&SERVICE=WMS&VERSION=1.0.0", "scaleLimit": "-", "inspireUpperAbstract": "Environnement, biology and geology | Space and population", "inspireName": "Environmental monitoring facilities | Human health and safety", "urlDetails": "http://www.bafu.admin.ch/hydrologie/01835/02122/index.html?lang=de", "abstract": "...", "inspireAbstract": "...", "dataOwner": "Federal Office for the Environment FOEN", "wmsContactAbbreviation": "swisstopo", "maps": "...", "wmsContactName": "Federal Office of Topography swisstopo", "dataStatus": "20130322", "inspireUpperName": "Environment biology and geology | Space and population", "urlApplication": "http://map.bafu.admin.ch" } } ], "tileInfo": { "origin": { "y": 350000, "x": 420000, "spatialReference": { "wkid": 21781 } }, "rows": 256, "format": "PNG,JPEG", "lods": [ { "height": 1, "width": 1, "scale": 14285750.5715, "resolution": 4000, "level": 0 }, ... { "height": 12500, "width": 18750, "scale": 357.1425, "resolution": 0.1, "level": 28 } ], "spatialReference": { "wkid": 21781 }, "cols": 256, "dpi": 96, "compressionQuality": "" }, "description": "Configuration for the map (topic) api", "fullExtent": { "xmin": 42000, "ymin": 30000, "ymax": 350000, "xmax": 900000, "spatialReference": { "wkid": 21781 } }, "units": "esriMeters", "initialExtent": { "xmin": 458000, "ymin": 76375, "ymax": 289125, "xmax": 862500, "spatialReference": { "wkid": 21781 } }, "spatialReference": { "wkid": 21781 }, "capabilities": "Map", "copyrightText": "Data api" } Here is a description of the data one can find in the above response. - **layers**: a list of object literals representing the layers - **name**: the name of the layer (short name less than 30 characters) - **fullName**: the layer's full name (not necessarily different from name) - **idGeoCat**: the associated metadata id in `GeoCat `_ - **layerBodId**: the technical name or BOD id - **attributes**: the metadata attributes associated to a given layer - **wmsResource**: the WMS resource of the layer - **scaleLimit**: the scale at which the layer is valid - **inspireUpperAbstract**: the abstract of the `INSPIRE `_ category (first level) - **inprireName**: the name of the `INSPIRE `_ category - **urlDetails**: link to the official details page - **bundCollectionNumber**: the collection number - **dataOwner**: the data owner - **inprieAbstract**: the abstract of the `INSPIRE `_ category the layer belongs to - **absctract**: the layer absctract - **wmsContactAbbreviation**: the abbreviation contact for the WMS resource - **downloadUrl**: the link where the data can be downloaded - **maps**: the projects in which this layer is accessible - **wmsContactName**: the contact name for the WMS resource - **dataStatus**: the date of the latest data update - **bundCollectionName**: the collection name - **inspireUpperName**: the name of the `INSPIRE `_ category (first level) - **urlApplication**: the application where this layer is published - **tileInfo**: WMTS general information in json format. Note that this section is always identical and is not tied to a particular "map" like in ESRI specifications. Examples ******** - List all the layers available in the GeoAdmin API: `https://api3.geo.admin.ch/rest/services/api/MapServer <../../../rest/services/api/MapServer>`_ - List all the layers available in the GeoAdmin API where the word "wasser" is found in their description: `https://api3.geo.admin.ch/rest/services/api/MapServer?searchText=wasser <../../../rest/services/api/MapServer?searchText=wasser>`_ - Find a layer by `geocat ID `_: `https://api3.geo.admin.ch/rest/services/api/MapServer?searchText=f198f6f6-8efa-4235-a55f-99767ea0206c <../../../rest/services/api/MapServer?searchText=f198f6f6-8efa-4235-a55f-99767ea0206c>`_ .. _layer_attributes_description: ---------- Layer Attributes ---------------- This service is used to expose the attributes names that are specific to a layer. This service is especially useful when combined wit h the find service. URL *** :: https://api3.geo.admin.ch/rest/services/api/MapServer/{layerBodId} Input Parameters **************** RESTFul interface is available. +-----------------------------------+-------------------------------------------------------------------------------------------+ | Parameters | Description | +===================================+===========================================================================================+ | **lang (optional)** | The language. Supported values: de, fr, it , rm, en. (Defaults to de if browser language | | | does not match any of the possible values) | +-----------------------------------+-------------------------------------------------------------------------------------------+ | **callback (optional)** | The name of the callback function. | +-----------------------------------+-------------------------------------------------------------------------------------------+ Example ******* Get the all the available attributes names of the municipal boundaries: `https://api3.geo.admin.ch/rest/services/api/MapServer/ch.swisstopo.swissboundaries3d-gemeinde-flaeche.fill <../../../rest/services/api/MapServer/ch.swisstopo.swissboundaries3d-gemeinde-flaeche.fill>`_ .. _legend_description: ---------- Legend Resource --------------- With a layer ID (or technical name), this service can be used to retrieve a legend. URL *** :: https://api3.geo.admin.ch/rest/services/api/MapServer/{layerBodId}/legend Input Parameters **************** No css styling is provided per default so that you can use your own. +-----------------------------------+-------------------------------------------------------------------------------------------+ | Parameters | Description | +===================================+===========================================================================================+ | **lang (optional)** | The language. Supported values: de, fr, it , rm, en. (Defaults to de if browser language | | | does not match any of the possible values) | +-----------------------------------+-------------------------------------------------------------------------------------------+ | **callback (optional)** | The name of the callback function. | +-----------------------------------+-------------------------------------------------------------------------------------------+ Example ******* - Get the legend for ch.bafu.nabelstationen: `https://api3.geo.admin.ch/rest/services/api/MapServer/ch.bafu.nabelstationen/legend <../../../rest/services/api/MapServer/ch.bafu.nabelstationen/legend>`_ - Get the same legend using JSONP: `https://api3.geo.admin.ch/rest/services/api/MapServer/ch.bafu.nabelstationen/legend?callback=callback <../../../rest/services/api/MapServer/ch.bafu.nabelstationen/legend?callback=callback>`_ .. _identify_description: ---------- Identify Features ----------------- This service can be used to discover features at a specific location. Here is a `complete list of layers <../../../api/faq/index.html#which-layers-have-a-tooltip>`_ for which this service is available. URL *** :: https://api3.geo.admin.ch/rest/services/api/MapServer/identify Input Parameters **************** No more than 50 features can be retrieved per request. +-----------------------------------+-------------------------------------------------------------------------------------------+ | Parameters | Description | +===================================+===========================================================================================+ | **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 or esriGeometryPolyline or esriGeometryPolygon or esriGeometryEnvelope. | +-----------------------------------+-------------------------------------------------------------------------------------------+ | **layers (optional)** | The layers to perform the identify operation on. Per default query all the layers in the | | | GeoAdmin API. Notation: all:"comma separated list of technical layer names". | +-----------------------------------+-------------------------------------------------------------------------------------------+ | **mapExtent (required)** | The extent of the map. (minx, miny, maxx, maxy). | +-----------------------------------+-------------------------------------------------------------------------------------------+ | **imageDisplay (required)** | The screen image display parameters (width, height, and dpi) of the map. | | | The mapExtent and the imageDisplay parameters are used by the server to calculate the | | | the distance on the map to search based on the tolerance in screen pixels. | +-----------------------------------+-------------------------------------------------------------------------------------------+ | **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. | +-----------------------------------+-------------------------------------------------------------------------------------------+ | **returnGeometry (optional)** | This parameter defines whether the geometry is returned or not. Default to "true". | +-----------------------------------+-------------------------------------------------------------------------------------------+ | **geometryFormat (optional)** | Returned geometry format. | | | Default 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). Defaults to "21781". | +-----------------------------------+-------------------------------------------------------------------------------------------+ | **lang (optional)** | The language. Supported values: de, fr, it , rm, en. Defaults to "de". | +-----------------------------------+-------------------------------------------------------------------------------------------+ | **callback (optional)** | The name of the callback function. | +-----------------------------------+-------------------------------------------------------------------------------------------+ Examples ******** - Identify all the features belonging to ch.bafu.nabelstationen using a tolerance of 5 pixels around a point: `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 <../../../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-1985 intersecting an enveloppe (or bounding box): `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-1985 <../../../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-1985>`_ - Identify all the features belonging to ch.bafu.bundesinventare-bln a polyline: `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 <../../../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: `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 <../../../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 than above but returned geometry format is GeoJSON: `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-1985&geometryFormat=geojson <../../../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-1985&geometryFormat=geojson>`_ - Same request than above but geometry is not returned: `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-1985&returnGeometry=false <../../../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-1985&returnGeometry=false>`_ Examples of Reverse Geocoding ***************************** The service identify can be used for Reverse Geocoding operations. Here is a `list of all the available layers <../../../api/faq/index.html#which-layers-are-available>`_. - Perform an identify request to find the districts intersecting a given enveloppe geometry (no buffer): `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 <../../../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): `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 <../../../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): `https://api3.geo.admin.ch/rest/services/api/MapServer/identify?mapExtent=0,0,100,100&imageDisplay=100,100,100&tolerance=1&geometryType=esriGeometryPoint&geometry=600968.625,197426.921875&layers=all:ch.bfs.gebaeude_wohnungs_register&returnGeometry=false <../../../rest/services/api/MapServer/identify?mapExtent=0,0,100,100&imageDisplay=100,100,100&tolerance=1&geometryType=esriGeometryPoint&geometry=600968.625,197426.921875&layers=all:ch.bfs.gebaeude_wohnungs_register&returnGeometry=false>`_ Simulate a search radius ************************ Equation: :: SearchRadius = Max(MapWidthInMeters / ScreenWidthInPx, MapHeightInMeters / ScreenHeightInPx) * toleranceInPx For instance if one wants a radius of 5 meters: :: Max(100 / 100, 100 / 100) * 5 = 5 So you would set: :: mapExtent=0,0,100,100&imageDisplay=100,100,100&tolerance=5&geometryType=esriGeometryPoint&geometry=548945,147956 to perform an identify request with a search radius of 5 meters around a given point. .. _find_description: ---------- Find ---- This service is used to search the attributes of features. Each result include a feature ID, a layer ID, a layer name, a geometry (optionally) and attributes in the form of name-value pair. Here is a `complete list of layers <../../../api/faq/index.html#which-layers-have-a-tooltip>`_ for which this service is available. URL *** :: https://api3.geo.admin.ch/rest/services/api/MapServer/find Input Parameters **************** One layer, one search text and one attribute. +-----------------------------------+-------------------------------------------------------------------------------------------+ | Parameters | Description | +===================================+===========================================================================================+ | **layer (required)** | A layer ID (only one layer at a time can be specified). | +-----------------------------------+-------------------------------------------------------------------------------------------+ | **searchText (required)** | The text to search for (one can use numerical values as well). | +-----------------------------------+-------------------------------------------------------------------------------------------+ | **searchField (required)** | The name of the field to search (only one search field can be searched at a time). | +-----------------------------------+-------------------------------------------------------------------------------------------+ | **contains (optional)** | If false, the operation searches for an exact match of the searchText string. An exact | | | match is case sensitive. Otherwise, it searches for a value that contains the searchText | | | string provided. This search is not case sensitive. The default is true. | +-----------------------------------+-------------------------------------------------------------------------------------------+ | **geometryFormat (optional)** | Returned geometry format. | | | Default to ESRI geometry format. Supported values are: "esrijson" or "geojson". | +-----------------------------------+-------------------------------------------------------------------------------------------+ | **returnGeometry (optional)** | This parameter defines whether the geometry is returned or not. Default to "true". | +-----------------------------------+-------------------------------------------------------------------------------------------+ | **sr (optional)** | The spatial reference. Supported values: 21781 (LV03), 2056 (LV95). Defaults to "21781". | +-----------------------------------+-------------------------------------------------------------------------------------------+ | **lang (optional)** | The language. Supported values: de, fr, it , rm, en. Defaults to "de". | +-----------------------------------+-------------------------------------------------------------------------------------------+ | **callback (optional)** | The name of the callback function. | +-----------------------------------+-------------------------------------------------------------------------------------------+ Examples ******** - Search for “Lavaux” in the field “bln_name” of the layer “ch.bafu.bundesinventare-bln” (infix match): `https://api3.geo.admin.ch/rest/services/api/MapServer/find?layer=ch.bafu.bundesinventare-bln&searchText=Lavaux&searchField=bln_name&returnGeometry=false <../../../rest/services/api/MapServer/find?layer=ch.bafu.bundesinventare-bln&searchText=Lavaux&searchField=bln_name&returnGeometry=false>`_ - Search for “12316” in the field “egid” of the layer “ch.bfs.gebaeude_wohnungs_register” (infix match): `https://api3.geo.admin.ch/rest/services/api/MapServer/find?layer=ch.bfs.gebaeude_wohnungs_register&searchText=123164&searchField=egid&returnGeometry=false <../../../rest/services/api/MapServer/find?layer=ch.bfs.gebaeude_wohnungs_register&searchText=123164&searchField=egid&returnGeometry=false>`_ - Search for “123164” in the field “egid” of the layer “ch.bfs.gebaeude_wohnungs_register” (exact match): `https://api3.geo.admin.ch/rest/services/api/MapServer/find?layer=ch.bfs.gebaeude_wohnungs_register&searchText=1231641&searchField=egid&returnGeometry=false&contains=false <../../../rest/services/api/MapServer/find?layer=ch.bfs.gebaeude_wohnungs_register&searchText=1231641&searchField=egid&returnGeometry=false&contains=false>`_ .. _featureresource_description: ---------- Feature Resource ---------------- With an ID (or several in a comma separated list) and a layer ID (technical name), this service can be used to retrieve a feature resource. Here is a `complete list of layers <../../../api/faq/index.html#which-layers-have-a-tooltip>`_ for which this service is available. URL *** :: https://api3.geo.admin.ch/rest/services/api/MapServer/{layerBodId}/{featureId},{featureId} Input Parameters **************** RESTFul interface is available. +-----------------------------------+-------------------------------------------------------------------------------------------+ | Parameters | Description | +===================================+===========================================================================================+ | **geometryFormat (optional)** | Returned geometry format. | | | Default to ESRI geometry format. Supported values are: "esrijson" or "geojson". | +-----------------------------------+-------------------------------------------------------------------------------------------+ | **returnGeometry (optional)** | This parameter defines whether the geometry is returned or not. Default to "true". | +-----------------------------------+-------------------------------------------------------------------------------------------+ | **sr (optional)** | The spatial reference. Supported values: 21781 (LV03), 2056 (LV95). Defaults to "21781". | +-----------------------------------+-------------------------------------------------------------------------------------------+ | **lang (optional)** | The language. Supported values: de, fr, it , rm, en. Defaults to "de". | +-----------------------------------+-------------------------------------------------------------------------------------------+ | **callback (optional)** | The name of the callback function. | +-----------------------------------+-------------------------------------------------------------------------------------------+ Example ******* - Get the feature with the ID RIG belonging to ch.bafu.nabelstationen: `https://api3.geo.admin.ch/rest/services/api/MapServer/ch.bafu.nabelstationen/RIG <../../../rest/services/api/MapServer/ch.bafu.nabelstationen/RIG>`_ - Get several features with IDs RIG and LAU belonging to ch.bafu.bundesinventar-bln: `https://api3.geo.admin.ch/rest/services/api/MapServer/ch.bafu.nabelstationen/RIG,LAU <../../../rest/services/api/MapServer/ch.bafu.nabelstationen/RIG,LAU>`_ .. _htmlpopup_description: ---------- Htmlpopup Resource ------------------ With an ID and a layer ID (technical name), this service can be used to retrieve an html popup. An html popup is an html formatted representation of the textual information about the feature. Here is a `complete list of layers <../../../api/faq/index.html#which-layers-have-a-tooltip>`_ for which this service is available. URL *** :: https://api3.geo.admin.ch/rest/services/api/MapServer/{layerBodId}/{featureId}/htmlPopup Input Parameters **************** No css styling is provided per default so that you can use your own. +-----------------------------------+-------------------------------------------------------------------------------------------+ | Parameters | Description | +===================================+===========================================================================================+ | **lang (optional)** | The language. Supported values: de, fr, it , rm, en. Defaults to "de". | +-----------------------------------+-------------------------------------------------------------------------------------------+ | **sr (optional)** | The spatial reference. Supported values: 21781 (LV03), 2056 (LV95). Defaults to "21781". | +-----------------------------------+-------------------------------------------------------------------------------------------+ | **time (optional)** | Time (YYYY) to filter out time enabled layers, e.g. LUBIS. Defaults to "none". | +-----------------------------------+-------------------------------------------------------------------------------------------+ | **callback (optional)** | The name of the callback function. | +-----------------------------------+-------------------------------------------------------------------------------------------+ Example ******* - Get the html popup with the feature ID RIG belonging to layer ch.bafu.nabelstationen: `https://api3.geo.admin.ch/rest/services/api/MapServer/ch.bafu.nabelstationen/RIG/htmlPopup <../../../rest/services/api/MapServer/ch.bafu.nabelstationen/RIG/htmlPopup>`_ .. _search_description: ---------- Search ------ The search service can be used to search for locations, layers or features. URL *** :: https://api3.geo.admin.ch/rest/services/api/SearchServer Description *********** The search service is separated in 3 various categories or types: * The **location search** which is composed of the following geocoded locations: * Cantons, Cities and communes * All names as printed on the national map (`SwissNames `_) * The districts * The ZIP codes * The addresses * The cadastral parcels * The **layer search** wich enables the search of layers belonging to the GeoAdmin API. * The **feature search** which is used to search through features descriptions. Note: you can also specify a bounding box to filter the features. (`Searchable layers <../../../api/faq/index.html#which-layers-are-searchable>`_) Input parameters **************** Only RESTFul interface is available. **Location Search** +-------------------------------------+-------------------------------------------------------------------------------------------+ | Parameters | Description | +=====================================+===========================================================================================+ | **searchText (required/optional)** | Must be provided if the `bbox` is not. The text to search for. Maximum of 10 words. | +-------------------------------------+-------------------------------------------------------------------------------------------+ | **type (required)** | The type of performed search. Specify `locations` to perform a location search. | +-------------------------------------+-------------------------------------------------------------------------------------------+ | **bbox (required/optional)** | Must be provided if the `searchText` is not. A comma separated list of 4 coordinates | | | representing the bounding box on which features should be filtered (SRID: 21781). | +-------------------------------------+-------------------------------------------------------------------------------------------+ | **sortbbox (optional)** | When `bbox` is specified and this parameter is "true", then the ranking of the results is | | | performed according to the distance between the locations and the center of the bounding | | | box. Default to "true". | +-------------------------------------+-------------------------------------------------------------------------------------------+ | **returnGeometry (optional)** | This parameter defines whether the geometry is returned or not. Default to "true". | +-------------------------------------+-------------------------------------------------------------------------------------------+ | **origins (optional)** | A comma separated list of origins. Possible origins are: | | | zipcode,gg25,district,kantone,gazetteer,address,parcel | | | A description of the origins can be found hereunder. Per default all origins are used. | +-------------------------------------+-------------------------------------------------------------------------------------------+ | **limit (optional)** | The maximum number of results to retrive per request (Max and default limit=50) | +-------------------------------------+-------------------------------------------------------------------------------------------+ | **sr (optional)** | The spatial reference. Supported values: 21781 (LV03), 2056 (LV95). Defaults to "21781". | +-------------------------------------+-------------------------------------------------------------------------------------------+ | **callback (optional)** | The name of the callback function. | +-------------------------------------+-------------------------------------------------------------------------------------------+ **Layer Search** +-----------------------------------+-------------------------------------------------------------------------------------------+ | Parameters | Description | +===================================+===========================================================================================+ | **searchText (required)** | The text to search for. Maximum of 10 words allowed. | +-----------------------------------+-------------------------------------------------------------------------------------------+ | **type (required)** | The type of performed search. Specify `layers` to perform a layer search. | +-----------------------------------+-------------------------------------------------------------------------------------------+ | **lang (optional)** | The language metadata. Supported values: de (default), fr, it, rm, en. | +-----------------------------------+-------------------------------------------------------------------------------------------+ | **limit (optional)** | The maximum number of results to retrive per request (Max and default limit=30) | +-----------------------------------+-------------------------------------------------------------------------------------------+ | **sr (optional)** | The spatial reference. Supported values: 21781 (LV03), 2056 (LV95). Defaults to "21781". | +-----------------------------------+-------------------------------------------------------------------------------------------+ | **callback (optional)** | The name of the callback function. | +-----------------------------------+-------------------------------------------------------------------------------------------+ **Feature Search** +-----------------------------------+-------------------------------------------------------------------------------------------+ | Parameters | Description | +===================================+===========================================================================================+ | **searchText (required)** | The text to search for (in features detail field). Maximum of 10 words allowed. | +-----------------------------------+-------------------------------------------------------------------------------------------+ | **type (required)** | The type of performed search. Specify `featuresearch` to perform a feature search. | +-----------------------------------+-------------------------------------------------------------------------------------------+ | **bbox (optional)** | A comma separated list of 4 coordinates representing the bounding box according to which | | | features should be ordered (SRID: 21781). | +-----------------------------------+-------------------------------------------------------------------------------------------+ | **sortbbox (optional)** | When `bbox` is specified and this parameter is "true", then the ranking of the results is | | | performed according to the distance between the locations and the center of the bounding | | | box. Default to "true". | +-----------------------------------+-------------------------------------------------------------------------------------------+ | **features (required)** | A comma separated list of technical layer names. | +-----------------------------------+-------------------------------------------------------------------------------------------+ | **limit (optional)** | The maximum number of results to retrive per request (Max and default limit=20) | +-----------------------------------+-------------------------------------------------------------------------------------------+ | **sr (optional)** | The spatial reference. Supported values: 21781 (LV03), 2056 (LV95). Defaults to "21781". | +-----------------------------------+-------------------------------------------------------------------------------------------+ | **callback (optional)** | The name of the callback function. | +-----------------------------------+-------------------------------------------------------------------------------------------+ Response syntax *************** The results are presented as a list of object literals. Here is an example of response for location search. .. code-block:: javascript results: [ { id: 206, weight: 12, attrs: { origin: "gg25", layerBodId: "ch.swisstopo.swissboundaries3d-gemeinde-flaeche.fill", featureId: "351", detail: "bern be", rank: 2, geom_st_box2d: "BOX(589008 196443.046875,604334.3125 204343.5)", num: 1, y: 598637.3125, x: 200393.28125, label: "Bern (BE)" } } ] Here is a description of the data one can find in the above response. - **id**: This is an internal value and therefore shouldn't be used. - **weight**: The `weight` is dynamically computed according to the `searchText` that is provided. It informs the user about how close an entry is to the provided `searchText`. - **attrs**: The attributes associated to a given entry. - **origin**: This attribute refers to the type of data an entry stands for. - **layerBodId**: The id of the associated layer (if any) - **featureId**: If available the object's Id can be combined with the `layerBodId` to collect more information about a feature. - **detail**: The search field - **rank**: A different `rank` is associated to each origin. Results are always ordered in ascending ranks. - **geom_st_box2d**: This attribute is in is in CH1903 / LV03 (EPSG:21781) reference system and represents the bounding box of the associated geometry. - **num**: This attribute is only valid for locations with **address** `origin`. It refers to the street number. - **x and y**: These attributes represent the coordinates of an entry. If an object's entry is a line or a polygon, those coordinates will always be on the underlying geometry. - **label**: The html label for an entry. Here is a list of possible origins sorted in ascending ranking order: - zipcode (ch.swisstopo-vd.ortschaftenverzeichnis_plz) - gg25 (ch.swisstopo.swissboundaries3d-gemeinde-flaeche.fill) - district (ch.swisstopo.swissboundaries3d-bezirk-flaeche.fill) - kantone (ch.swisstopo.swissboundaries3d-kanton-flaeche.fill) - gazetteer (ch.swisstopo.swissnames3d, ch.bav.haltestellen-oev) - address (ch.bfs.gebaeude_wohnungs_register with EGID or use prefix 'addresse', 'adresse', 'indirizzo', 'address' without EGID) - parcel (use prefix "parcel", "parzelle", "parcelle" or "parcella" in your requests to filter out other origins) Prefix filtering cannot be combined with parameter `origins`. Examples ******** - Search for locations matching the word “wabern”: `https://api3.geo.admin.ch/rest/services/api/SearchServer?searchText=wabern&type=locations <../../../rest/services/api/SearchServer?searchText=wabern&type=locations>`_ - Search for locations of type "parcel" and "district" (the origins): `https://api3.geo.admin.ch/rest/services/api/SearchServer?searchText=bern&origins=parcel,district&type=locations <../../../rest/services/api/SearchServer?searchText=bern&origins=parcel,district&type=locations>`_ - Search for locations within a given map extent (the `bbox`): `https://api3.geo.admin.ch/rest/services/api/SearchServer?bbox=551306.5625,167918.328125,551754.125,168514.625&type=locations <../../../rest/services/api/SearchServer?bbox=551306.5625,167918.328125,551754.125,168514.625&type=locations>`_ - Search for layers in French matching the word “géoïde” in their description: `https://api3.geo.admin.ch/rest/services/api/SearchServer?searchText=géoïde&type=layers&lang=fr <../../../rest/services/api/SearchServer?searchText=géoïde&type=layers&lang=fr>`_ - Search for features matching word "433" in their description: `https://api3.geo.admin.ch/rest/services/api/SearchServer?features=ch.bafu.hydrologie-gewaesserzustandsmessstationen&type=featuresearch&searchText=433 <../../../rest/services/api/SearchServer?features=ch.bafu.hydrologie-gewaesserzustandsmessstationen&type=featuresearch&searchText=433>`_ Example of feature search usage with other services *************************************************** - First: search for addresses using the feature search service: `https://api3.geo.admin.ch/rest/services/api/SearchServer?features=ch.bfs.gebaeude_wohnungs_register&type=featuresearch&searchText=isabelle <../../../rest/services/api/SearchServer?features=ch.bfs.gebaeude_wohnungs_register&type=featuresearch&searchText=isabelle>`_ - Then: use "feature_id" found in "attrs" to get detailed information about a feature: `https://api3.geo.admin.ch/rest/services/api/MapServer/ch.bfs.gebaeude_wohnungs_register/880711_0?returnGeometry=false <../../../rest/services/api/MapServer/ch.bfs.gebaeude_wohnungs_register/880711_0?returnGeometry=false>`_ .. _height_description: ---------- Height ------ This service allows to obtain elevation information for a point. See `Height models `_ for more details about data used by this service. .. warning:: This service is not freely accessible (fee required). `Please Contact us `_ URL *** :: https://api3.geo.admin.ch/rest/services/height Input Parameters **************** RESTFul interface is available. +--------------------------------+-----------------------------------------------------------------------------------------+ | Parameters | Description | +================================+=========================================================================================+ | **easting (required)** | The easting coordinate in LV03 (EPSG:21781) or LV95 (EPSG:2056) | +--------------------------------+-----------------------------------------------------------------------------------------+ | **northing (required)** | The northing coordinate in LV03 (EPSG:21781) or LV95 (EPSG:2056) | +--------------------------------+-----------------------------------------------------------------------------------------+ | **elevation_model (optional)** | The elevation model. Three elevation models are available DTM25, DTM2 (swissALTI3D) | | | and COMB (a combination of DTM25 and DTM2). Default to "DTM25". | +--------------------------------+-----------------------------------------------------------------------------------------+ | **sr(optional)** | The reference system to use (EPSG code). Valid values are 2056 (for LV95) and 21781 | | | (for )LV03). If not given, trying to guess which one to use. | +--------------------------------+-----------------------------------------------------------------------------------------+ | **callback (optional)** | The name of the callback function. | +--------------------------------+-----------------------------------------------------------------------------------------+ Examples ******** - `https://api3.geo.admin.ch/rest/services/height?easting=2600000&northing=1200000 <../../../rest/services/height?easting=2600000&northing=1200000>`_ .. _profile_description: ---------- Profile ------- This service allows to obtain elevation information for a polyline in CSV format. See `Height models `_ for more details about data used by this service. .. warning:: This service is not freely accessible (fee required).** `Please Contact us `_ URL *** :: https://api3.geo.admin.ch/rest/services/profile.json (for json format) https://api3.geo.admin.ch/rest/services/profile.csv (for a csv) Input Parameters **************** RESTFul interface is available. +-----------------------------------+-------------------------------------------------------------------------------------------+ | Parameters | Description | +===================================+===========================================================================================+ | **geom (required)** | A GeoJSON representation of a polyline (type = LineString). The LineString should not | | | have more than 6'000 coordinates. | +-----------------------------------+-------------------------------------------------------------------------------------------+ | **sr (optional)** | The reference system to use (EPSG code). Valid value are 2056 (for LV95) and 21781 (for | | | LV03). Strongly advised to set one, but if not given, trying to guess which one to use. | +-----------------------------------+-------------------------------------------------------------------------------------------+ | **elevation_models (optional)** | A comma separated list of elevation models. Three elevation models are available DTM25, | | | DTM2 (swissALTI3D) and COMB (a combination of DTM25 and DTM2). Default to "DTM25". | +-----------------------------------+-------------------------------------------------------------------------------------------+ | **nb_points (optional)** | The number of points used for the polyline segmentation. Default "200". | +-----------------------------------+-------------------------------------------------------------------------------------------+ | **offset (optional)** | The offset value (INTEGER) in order to use the `exponential moving algorithm | | | `_ . For a given | | | value the offset value specify the number of values before and after used to calculate | | | the average. | +-----------------------------------+-------------------------------------------------------------------------------------------+ | **callback (optional)** | Only available for **profile.json**. The name of the callback function. | +-----------------------------------+-------------------------------------------------------------------------------------------+ Example ******* - A profile in JSON: `https://api3.geo.admin.ch/rest/services/profile.json?geom={"type"%3A"LineString"%2C"coordinates"%3A[[2550050%2C1206550]%2C[2556950%2C1204150]%2C[2561050%2C1207950]]}&sr=2056 <../../../rest/services/profile.json?geom={"type"%3A"LineString"%2C"coordinates"%3A[[2550050%2C1206550]%2C[2556950%2C1204150]%2C[2561050%2C1207950]]}>`_ - A profile in CSV: `https://api3.geo.admin.ch/rest/services/profile.csv?geom={"type"%3A"LineString"%2C"coordinates"%3A[[2550050%2C1206550]%2C[2556950%2C1204150]%2C[2561050%2C1207950]]}&sr=2056 <../../../rest/services/profile.csv?geom={"type"%3A"LineString"%2C"coordinates"%3A[[2550050%2C1206550]%2C[2556950%2C1204150]%2C[2561050%2C1207950]]}>`_ ---------- .. _wmts_description: WMTS ---- A RESTFul implementation of the `WMTS `_ `OGC `_ standard. For detailed information, see `WMTS OGC standard `_ .. warning:: In order to have access to the WMTS, you require to register to `swisstopo web access - Inscription form`_ (in German), even if most layers are free to use. See :ref:`available_layers` for a list of all available layers. .. note:: Only the RESTFul request encoding to `GetTile` is implemented, not the `GetLegend` and `GetFeatureInfo`. No KVP and SOAP request encoding is supported. GetCapabilities *************** The GetCapabilites document provides informations about the service, along with layer description, both in german and french. `https://wmts.geo.admin.ch/1.0.0/WMTSCapabilities.xml `_ `https://wmts.geo.admin.ch/1.0.0/WMTSCapabilities.xml?lang=fr `_ GetTile ******* :: ://////