Reverse Geocoding Service

Reverse geocoding is the process of back (reverse) coding of a point location (latitude, longitude) to a readable address or place name.

Prerequisites

Before you begin, make sure you have:

Reverse Geocode

Given a point (-81.023012, 34.014671) which longitude is -81.023012 and latitude is 34.014671, the query below show how to get the related readable address.

Reverse Geocode
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"""
Variables:
 
"""
query {
    geodecode(x: -81.023012, y: 34.014671) {  
        elements {
            element {
                postal_address {
                    city
                    country
                    country_code
                    county
                    district
                    opposite_street_number
                    postal_code
                    state
                    street
                    street_number
                }
                coordinate {
                    x
                    y
                }
                angle
                speed_limit
            }
        }
    }
}
1
2
3
4
5
6
export TOKEN=<YOUR_MUNIC_CONNECT_TOKEN>

curl --request POST 'https://api.dev.munic.io/services/ekko/master/graphql' \
--header "Authorization: Bearer $TOKEN" \
--header "Content-Type: application/json" \
--data '{"query": "query {\n    geodecode(x: -81.023012, y: 34.014671) {  \n        elements {\n            element {\n                postal_address {\n                    city\n                    country\n                    country_code\n                    county\n                    district\n                    opposite_street_number\n                    postal_code\n                    state\n                    street\n                    street_number\n                }\n                coordinate {\n                    x\n                    y\n                }\n                angle\n                speed_limit\n            }\n        }\n    }\n}", "variables":}'
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import requests

token = <YOUR_MUNIC_CONNECT_TOKEN>
url = "https://api.dev.munic.io/services/ekko/master/graphql"

payload = """
{"query": "query {
    geodecode(x: -81.023012, y: 34.014671) {  
        elements {
            element {
                postal_address {
                    city
                    country
                    country_code
                    county
                    district
                    opposite_street_number
                    postal_code
                    state
                    street
                    street_number
                }
                coordinate {
                    x
                    y
                }
                angle
                speed_limit
            }
        }
    }
}", "variables":}
"""

payload = payload.replace("\n", "")

headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer %s'%(token)
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
See JSON Answer
{
    "data": {
        "geodecode": {
            "elements": {
                "element": [
                    {
                        "angle": 160.0,
                        "coordinate": {
                            "x": -81.02301,
                            "y": 34.01467
                        },
                        "postal_address": {
                            "city": "Columbia",
                            "country": "United States",
                            "country_code": "USA",
                            "county": "Richland",
                            "district": "",
                            "opposite_street_number": "1900",
                            "postal_code": "29204",
                            "state": "South Carolina",
                            "street": "Harden St",
                            "street_number": "1900"
                        },
                        "speed_limit": 56.32443
                    }
                ]
            }
        }
    }
}

For more details, please read geodecode documentation graphql reference.