reverse_geocoder
When you use this function in a query, it takes the latitude and longitude values in a dataset and returns information such as ISO 3166-1 alpha-3 codes or a country name based on the shapes available in the layer referenced in the query rule.
For more information on ISO 3166-1 alpha-3, see http://www.iso.org/iso/home/standards/country_codes.htm.
For more information on determining which layers are available, see Layers.
For more information on using query functions and operators in a REST API request, see Queries. For an end-to-end description of how to create a query, see Creating a Query.
The example below assumes the following dataset is in the system (a311282f85904f2bb59d3d1c81eeb962
in this case, but the ID is different for different accounts).
Lat;Lon;City
52.516667;13.383333;Berlin
41.836944;-87.684722;Chicago
39.916667;116.383333;Beijing
In this case, the example query creates a response with ISO-3 country codes based on the Lat, Lon values in the dataset.
{
"facets": [
"iso3"
],
"version": 0.3,
"namespace": {
"iso3": {
"source": [
"lat",
"lon"
],
"apply": [
{
"params": [
"here_country",
"iso3"
],
"type": "transform",
"fn": "reverse_geocoding"
}
]
},
},
"dataset": "a311282f85904f2bb59d3d1c81eeb962"
}
When you submit the above request, the response includes an HTTP status code and the following JSON response body.
{
"query": "339f0660252345129379a6e8f1380cfb",
"kind": "datalens#query_result",
"rows": [
["CHN"],
["USA"],
["DEU"]
],
"columns": ["iso3"],
"dataset": "a311282f85904f2bb59d3d1c81eeb962"
}
In this case, the params
values specify that the layer here_country
is used to determine the owning administrative entity of the geocoordinates defined by the latitude and longitude values. This layer provides country names, HERE IDs, and ISO 3166-1 alpha-3 country codes. If you changed the query above to the following query rule, then the response contains the country names.
{
"facets": ["name"],
"version": 0.3,
"namespace": {
"name": {
"source": [
"lat",
"lon"
],
"apply": [{
"params": [
"here_country",
"name"
],
"type": "transform",
"fn": "reverse_geocoding"
}]
},
},
"dataset": "a311282f85904f2bb59d3d1c81eeb962"
}
{
"query": "3eeebdd41c084ed08d6de6024f3056cb",
"kind": "datalens#query_result",
"rows": [
["United States"],
["Germany"],
["China"]
],
"columns": ["name"],
"dataset": "a311282f85904f2bb59d3d1c81eeb962"
}
For more information on the HTTP status codes, see HTTP Status Codes.
For more information on the elements in the JSON structure in the response body, see Query.