Reverse geocoding guide

Practical guide with examples: finding the nearest address from coordinates, output formats, detail mode and coordinate order across formats.

Live examples. Requests and responses were made against https://pump.elemroot.com/rgc4 (key key=docs_3d4e64fa1755d7299cb78bf6, dataset gl=ee_lt_lv, service s=ADDRESS).
Contents

Endpoint and methods

The service supports the GET and POST methods (POST with application/x-www-form-urlencoded). NB: with POST the key must be in the query string (the URL); a key given only in the form body is not seen by the key check and the response is 403.

MethodURL
GEThttps://pump.elemroot.com/rgc4/revgeocode
POSThttps://pump.elemroot.com/rgc4/revgeocode
GEThttps://pump.elemroot.com/rgc4_lyh/revgeocode ("lyh": same API and JSON structure, shorter address form: EE, Tartumaa, Tartu, …)

Parameter reference

ParamMeaningAllowed values / exampleDefault
q *Input point lat,lon (latitude first; repeat = batch)58.3957739,26.7462826—
gl *Dataset. ee_lt_lv_aid adds AADRESS_ID to the detail response (Estonian, Latvian and Lithuanian points); ee_lt_lv_kt and ee_lt_lv_aid_kt add KATASTRITUNNUS (Estonian points)ee_lt_lv, ee_lt_lv_aid, ee_lt_lv_kt, ee_lt_lv_aid_kt—
s *Rule set; required. The _reverse suffix reverses the component order of the address string (most specific first)ADDRESS, ADDRESS_reverse—
outputOutput formatjson, json2, xml, xml2, kml, ads_liik_staatusjson
key *API key (without it: 403)docs_3d4e64fa1755d7299cb78bf6 (demo)—
srsInput and output coordinates. distance is in metres only when srs is omitted or is exactly EPSG:4326 or WGS84EPSG:4326, EPSG:3301 (case-insensitive; also wgs84): anything else returns 500EPSG:4326
lMax length of the formatted address in characters (not an address level)integer—
detailAdd structured componentsempty, true, false—
replaceTypeType code rename (repeatable)A5 street—
callbackJSONP callbackfunction name, e.g. cb—

Datasets: gl=ee_lt_lv (Estonia, Latvia, Lithuania), gl=ee_lt_lv_aid (the same, plus AADRESS_ID), gl=ee_lt_lv_kt and gl=ee_lt_lv_aid_kt (plus KATASTRITUNNUS for Estonian points); the rule set is s=ADDRESS (or s=ADDRESS_reverse: components reversed, see below).

First request

Request
curl "https://pump.elemroot.com/rgc4/revgeocode?q=58.3957739405547,26.7462826320901&gl=ee_lt_lv&s=ADDRESS&key=docs_3d4e64fa1755d7299cb78bf6"
Response (json)
[
  {
    "distance": 4.6902068828416404E-4,
    "name": "58.3957739405547,26.7462826320901",
    "placemark": {
      "address": "EE, Tartu maakond, Tartu linn, Tartu linn, Muuseumi tee 2",
      "point": { "coordinates": [26.74628262527919, 58.39577393830106] }
    }
  }
]

distance is the distance between the input point and the found address in metres (the value may come in exponent form, e.g. 4.69E-4 = 0.47 mm). placemark is one object (not an array). name echoes the input coordinates.

Note: distance and srs. The distance is in metres only when srs is omitted or is exactly EPSG:4326 or WGS84 (upper case). With any other spelling (epsg:4326, wgs84, EPSG:3301) distance is in degrees; do not interpret it as metres. The code itself is case-insensitive (epsg:3301 works); l-est97 does not work in reverse geocoding (500).
Input q = lat,lon. First number is latitude (N), second is longitude (E). System is srs (default EPSG:4326).

How the match is chosen

Every input coordinate returns exactly one match. Several points can be queried in one request by repeating the q parameter; responses come back in the same order.

Near a state border the nearest address point wins regardless of country: a point on the Estonian side may get a Latvian address if the nearest building is in Latvia.

Components reversed (s=ADDRESS_reverse)

The _reverse suffix in the rule set name reverses the component order of the address string (most specific first). Handy for direct display or shortening. Coordinates, distance and the structured AddressLines (detail) do not change. The suffix is lower case (ADDRESS_REVERSE returns 500).

Request
curl "https://pump.elemroot.com/rgc4/revgeocode?q=58.3957739405547,26.7462826320901&gl=ee_lt_lv&s=ADDRESS_reverse&key=docs_3d4e64fa1755d7299cb78bf6"
Response (json)
[
  {
    "distance": 4.6902068828416404E-4,
    "name": "58.3957739405547,26.7462826320901",
    "placemark": {
      "address": "Muuseumi tee 2, Tartu linn, Tartu linn, Tartu maakond, EE",
      "point": { "coordinates": [26.74628262527919, 58.39577393830106] }
    }
  }
]

The same request with s=ADDRESS gives "EE, Tartu maakond, Tartu linn, Tartu linn, Muuseumi tee 2". Works on /rgc4_lyh too ("Muuseumi tee 2, Tartu, Tartu, Tartumaa, EE").

Address components (detail)

By default only address text, coordinates and distance are returned. For structured components add detail (and use json2/xml2):

Request
curl "https://pump.elemroot.com/rgc4/revgeocode?q=58.3957739405547,26.7462826320901&gl=ee_lt_lv&s=ADDRESS&output=json2&detail&key=docs_3d4e64fa1755d7299cb78bf6"
Response (json2)
[
  {
    "distance": 4.6902068828416404E-4,
    "name": "58.3957739405547,26.7462826320901",
    "placemark": {
      "address": "EE, Tartu maakond, Tartu linn, Tartu linn, Muuseumi tee 2",
      "AddressDetails": {
        "AddressLines": [
          { "Type": "A0",      "Value": "Eesti Vabariik" },
          { "Type": "A1",      "Value": "Tartu maakond" },
          { "Type": "A2",      "Value": "Tartu linn" },
          { "Type": "A3",      "Value": "Tartu linn" },
          { "Type": "A5",      "Value": "Muuseumi tee" },
          { "Type": "A7",      "Value": "2" },
          { "Type": "POSTCODE","Value": "60532" },
          { "Type": "A1_EHAK", "Value": "0079" },
          { "Type": "A2_EHAK", "Value": "0793" },
          { "Type": "A3_EHAK", "Value": "8151" }
        ]
      },
      "point": { "coordinates": [26.74628262527919, 58.39577393830106] }
    }
  }
]
Note. In json output AddressDetails stays empty ({}) even with detail: typed components come from json2/xml2.

Latvian and Lithuanian components

Latvian and Lithuanian points use the same type codes, but the set differs:

Output formats

output: json, json2, xml, xml2, kml, ads_liik_staatus.

xml2

curl "https://pump.elemroot.com/rgc4/revgeocode?q=58.3957739405547,26.7462826320901&gl=ee_lt_lv&s=ADDRESS&output=xml2&detail&key=docs_3d4e64fa1755d7299cb78bf6"
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<kml xmlns="http://earth.google.com/kml/2.0">
<Response>
<name>58.3957739405547,26.7462826320901</name>
<distance>4.6902068828416404E-4</distance>
<Placemark>
<Point><coordinates>58.39577393830106,26.74628262527919</coordinates></Point>
<address>EE, Tartu maakond, Tartu linn, Tartu linn, Muuseumi tee 2</address>
<AddressDetails>
<AddressLine Type="A0">Eesti Vabariik</AddressLine>
<AddressLine Type="A1">Tartu maakond</AddressLine>
<AddressLine Type="A2">Tartu linn</AddressLine>
<AddressLine Type="A3">Tartu linn</AddressLine>
<AddressLine Type="A5">Muuseumi tee</AddressLine>
<AddressLine Type="A7">2</AddressLine>
<AddressLine Type="POSTCODE">60532</AddressLine>
<AddressLine Type="A1_EHAK">0079</AddressLine>
<AddressLine Type="A2_EHAK">0793</AddressLine>
<AddressLine Type="A3_EHAK">8151</AddressLine>
</AddressDetails>
</Placemark>
</Response>
</kml>

Unlike geocoding, reverse geocoding xml2 has no <AddressLines> wrapper: <AddressLine> elements sit directly under <AddressDetails>.

Coordinate order

Attention: order differs between formats:

Input q is always lat,lon (N,E).

ads_liik_staatus

Returns the address of an Estonian point as Estonian-named fields, with distance:

curl "https://pump.elemroot.com/rgc4/revgeocode?q=58.3957739405547,26.7462826320901&gl=ee_lt_lv&s=ADDRESS&output=ads_liik_staatus&detail&key=docs_3d4e64fa1755d7299cb78bf6"
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<aadressideNimekiri>
<aadress>
<aadressSisse>58.3957739405547,26.7462826320901</aadressSisse>
<kaugus>4.6902068828416404E-4</kaugus>
<vaste>
<maakondEhak>0079</maakondEhak>
<maakond>Tartu maakond</maakond>
<omavalitsusEhak>0793</omavalitsusEhak>
<omavalitsus>Tartu linn</omavalitsus>
<asustusyksusEhak>8151</asustusyksusEhak>
<asustusyksus>Tartu linn</asustusyksus>
<liikluspind>Muuseumi tee</liikluspind>
<aadressinumber>2</aadressinumber>
<sihtnumber>60532</sihtnumber>
<aadressValja>EE, Tartu maakond, Tartu linn, Tartu linn, Muuseumi tee 2</aadressValja>
<koordinaadid>26.74628262527919,58.39577393830106</koordinaadid>
</vaste>
</aadress>
</aadressideNimekiri>

Which combination to use

TaskCombinationWhy
Point → address + distance in metresgl=ee_lt_lv&s=ADDRESSdefault EPSG:4326; distance is in metres
Address components as separate fieldsoutput=json2&detail=truereturns AddressLines with type codes
Address fields with Estonian namesoutput=ads_liik_staatus&detail=truedetail is required for this format
Shorter address text/rgc4_lyh/revgeocodesame JSON, shorter address string
Address most-specific-first (Muuseumi tee 2, Tartu linn, …)s=ADDRESS_reverseonly the order of the address string changes; for display and shortening
An address id for the pointgl=ee_lt_lv_aid&detail=trueAddressLines gets an AADRESS_ID line for Estonian, Latvian and Lithuanian points alike; also works on /rgc4_lyh
Point with cadastral identifiergl=ee_lt_lv_aid_kt&detail=trueAddressLines gets the AADRESS_ID and KATASTRITUNNUS lines (the identifier for Estonian points); several parcels are in one line separated by semicolons, the one containing the address point first
Example: address id for a point in one request
curl "https://pump.elemroot.com/rgc4/revgeocode?q=58.3957739,26.7462826&gl=ee_lt_lv_aid&s=ADDRESS&output=json2&detail=true&key=docs_3d4e64fa1755d7299cb78bf6"
Response (json2, abridged): the last line is the address id
"AddressLines": [ …, {"Type": "A7", "Value": "2"}, {"Type": "POSTCODE", "Value": "60532"}, …, {"Type": "AADRESS_ID", "Value": "3069760"} ]
Example: the same for a Latvian point
curl "https://pump.elemroot.com/rgc4/revgeocode?q=57.520503,25.390738&gl=ee_lt_lv_aid&s=ADDRESS&output=json2&detail=true&key=docs_3d4e64fa1755d7299cb78bf6"
Response (abridged)
"AddressLines": [ …, {"Type": "A7", "Value": "195 k-1"}, {"Type": "POSTCODE", "Value": "4201"}, {"Type": "AADRESS_ID", "Value": "101020361"} ]

A Latvian or Lithuanian AADRESS_ID can be used directly: pass it to geocoding with aidq=true (gl=lv / gl=lt), and with a level prefix also to the address selection (gazetteer).

Example: cadastral identifier for a point
curl "https://pump.elemroot.com/rgc4/revgeocode?q=58.3957739,26.7462826&gl=ee_lt_lv_aid_kt&s=ADDRESS&output=json2&detail=true&key=docs_3d4e64fa1755d7299cb78bf6"
Response (abridged)
"AddressLines": [ …, {"Type": "POSTCODE", "Value": "60532"}, …, {"Type": "AADRESS_ID", "Value": "3069760"}, {"Type": "KATASTRITUNNUS", "Value": "79512:033:0039"} ]

The cadastral identifier is given for Estonian points only; Latvian and Lithuanian responses stay the same as with gl=ee_lt_lv_aid. Meaning of the line and the format for several parcels: Address search guide.

Two traps. The input q is lat,lon (latitude first), while the JSON response point.coordinates is [E, N]. And distance is in metres only when srs is omitted or is exactly EPSG:4326 or WGS84; srs=EPSG:3301, but also epsg:4326 or wgs84, yield a degree-based number.

Error handling

SituationCodeMessage
gl missing500No service provided in the request. Use request parameter gl
Dataset not supported500<gl>: this service is not supported
s missing500—
s value not supported500Unknown serviceId: <s>
q missing400q missing in query
q invalid400q is not correct
l invalid400l is not correct
detail invalid400detail is not correct
Format requires detail=true400output format <x> only supported with URL parameter detail=true
Unknown output400<format>: unknown output format
Invalid replaceType rule400<rule>: bad replacement rule
Missing or wrong API key403{"error":"invalid_api_key"} (JSON)

API reference (Swagger UI) → Interactive try-it-out. OpenAPI spec (YAML file) → Machine-readable API description for tooling. Note: opens as a raw YAML file.