reverse_geocoding

Reverse Geocoding

reverse_geocode() function signature and parameters

In [1]:
from arcgis import geocoding
from arcgis.gis import *
from getpass import getpass
In [2]:
password= getpass()
gis = GIS("https://esriwebgis.webgistesting.net/portal","atma.mani",password)
········
In [3]:
results = geocoding.reverse_geocode([2.2945, 48.8583])
In [4]:
results
Out[4]:
{'address': {'Address': '6 Avenue Gustave Eiffel',
  'City': 'Paris',
  'CountryCode': 'FRA',
  'Loc_name': 'FRA.PointAddress',
  'Match_addr': '6 Avenue Gustave Eiffel, 75007, 7e Arrondissement, Paris, Île-de-France',
  'Neighborhood': '7e Arrondissement',
  'Postal': '75007',
  'PostalExt': None,
  'Region': 'Île-de-France',
  'Subregion': 'Paris'},
 'location': {'spatialReference': {'latestWkid': 4326, 'wkid': 4326},
  'x': 2.29465293958984,
  'y': 48.85748501186063}}

Example: Reverse geocode location specified as a Point geometry

In [5]:
from arcgis.geometry import Geometry
In [6]:
pt = Geometry({
    "x": 11563503,
    "y": 148410,
    "spatialReference": {
        "wkid": 3857
    }
})
In [7]:
results = geocoding.reverse_geocode(pt)
In [8]:
results
Out[8]:
{'address': {'Address': '40 Lichi Avenue',
  'City': None,
  'CountryCode': 'SGP',
  'Loc_name': 'SGP.PointAddress',
  'Match_addr': '40 Lichi Avenue, 348814, Singapore',
  'Neighborhood': None,
  'Postal': '348814',
  'PostalExt': None,
  'Region': None,
  'Subregion': None},
 'location': {'spatialReference': {'latestWkid': 4326, 'wkid': 4326},
  'x': 103.87671886128821,
  'y': 1.3330587058289018}}

Example: Reverse geocode a clicked location on the map

In [9]:
map1 = gis.map('150 S Tahquitz Canyon way, Palm Springs, CA', 16)
map1
134 E Tahquitz Canyon Way, Palm Springs, California, 92262
115 S Indian Canyon Dr, Palm Springs, California, 92262
205 S Belardo Rd, Palm Springs, California, 92262
In [10]:
def find_addr(map1, g):
    try:
        geocoded = geocoding.reverse_geocode(g)
        print(geocoded['address']['Match_addr'])
    except:
        print("Couldn't match address. Try another place...")
In [11]:
map1.on_click(find_addr)
In [ ]: