You will learn: how to find an address or place using the ArcGIS World Geocoding Service.

The geocoding module contains the geocode() function for forward geocoding that can be used to search for single field addresses, multi-field addresses, points of interest etc. The reverse_geocode() function can be used to find addresses of coordinates.

Before You Begin

The ArcGIS API for Python DevLabs use Jupyter Notebooks to execute Python code. If you are new to Python, please see the ArcGIS API for Python guide to Using the Jupyter notebook environment.


Geocode place names and addresses

  1. Go to the Esri Jupyter Notebook and click New > Python 3 to create a new notebook.

    In each step below, type (or copy and paste) the commands into a new notebook cell and run the code by clicking run cell or pressing shift + Enter.

  2. Add the following code in a cell to import the ArcGIS API for Python.

    from arcgis.gis import *
    from arcgis.geocoding import geocode, reverse_geocode
    from arcgis.geometry import Point
  3. Log into ArcGIS Online as an anonymous user.

    dev_gis = GIS()
  4. Search for the Hollywood sign.

    geocode_result = geocode(address="Hollywood sign", as_featureset=True)
  5. Display a map of Los Angeles to display the geocode result.

    map1 = dev_gis.map("Los Angeles, CA", zoomlevel=11)
  6. Draw the geocode result on the map.

  7. Clear the map and try geocoding the following addresses

    • Single line address: 380 New York St, Redlands, CA
    • Administrative place name: New York City
    • Zip code: 92354

Reverse geocode a coordinate

  1. Construct a Point geometry object for the following latitude and longitude: 34.13419,-118.29636

    location = {'Y':34.13419,'X':-118.29636,
    unknown_pt = Point(location)
  2. Reverse geocode the Point to get the address

    address = reverse_geocode(location=unknown_pt)

Congratulations, you're done!

Your notebook should look something like this