All tutorials

Using the what3words ArcGIS Locator within ArcGIS Pro

intermediate

The what3words ArcGIS Locator brings the functionality of the what3words API to the ArcGIS platform. You can use the Locator throughout the ArcGIS product suite wherever a custom locator can be added. This includes ArcGIS Desktop – ArcCatalog and ArcMap as well as ArcGIS Pro.

This tutorial goes through the different steps to use each of the tools ArcGIS Pro provides to search for 3 word address, discover 3 word address and carry out batch conversions.

1Get API key
Signup to create key
2Add the what3words Locator to ArcGIS Online

Follow this tutorial or watch this video to set up the what3words ArcGIS Locator within ArcGIS Online and add it as a Utility Service.

Getting started with Dazi, GIS Technical Account Manager at what3words:

3Search 3 word addresses

Click on the Map tab on the ArcGIS Ribbon. The Locate button will then be available to search for locations.

If you click on the button next to the search you will be able to see the locators available – the what3words Locator should be present.

You can then search for a 3 word address in the input field.

Suggestions for the 3 word address using our AutoSuggest functionality will appear after you begin typing the third word.

Click a result to zoom to the 3 word address.

4Discovering 3 word addresses

Right-click on the map and click on the What’s Here? option. This will then display all addresses from the available locators.

Select the what3words result to view the 3 word address and coordinates.

5Geocoding Tools

The what3words Locator can be used in any of the geocoding geoprocessing tools you have access to that accept a custom locator.

Click on the Analysis tab on the ArcGIS ribbon and the Tools button which will open the geoprocessing panel.

Search for geocode to bring back geocoding tools.

To geocode a layer of 3 word addresses (convert to coordinates from our API) the Geocode Addresses processing tool can be used.

You will need to specify the point layer to be used, the what3words Locator, the single field option and specify the field that the 3 word addresses lie within.

To reverse geocode a layer of points you can use the reverse geocode tool (convert to 3 word address from our API). You will need to specify the layer to find 3 word addresses for and the what3words Locator.

Note that the output of the Reverse Geocode tool is the points (ie. geometry) of the 3 word address and not the points of your original dataset.

Therefore we recommend doing the following to create a populated what3words column on your original dataset:

  1. Use the Reverse Geocode tool to create a new layer of the 3 word address points for your source layer.
  2. Add a “what3words” field to your original (source) layer.
  3. Run the following Python script in the Python window (View > Python Window) changing the variables at the start of your layers, the what3words field you have added, and the join field (ie your unique ID field)

Alternatively, you can manually do the same process as the Python script does by:

  1. Joining the new geocoded layer to the source layer joins on a unique ID.
  2. Update the what3words field using the field calculator taking the 3 word address from the new layer.
# Import the necessary arcpy module
import arcpy

# Paths to the source feature class and the reverse geocoded feature class
sourceFc = r"C:/Data/MyProject7.gdb/sourceLayer"  # Original source layer
geocodeFc = r"C:/Data/MyProject7.gdb/sourceLayer_ReverseGeocode"  # Reverse geocoded layer

# Define the ID field to join on, what3words field in the source layer, and the field from the reverse geocode layer
idFld = "ID"  # Field to join on
w3wFld = "what3words"  # Field in the source layer to update with what3words addresses
reverseFld = "REV_Match_addr"  # Field from reverse geocode layer containing the 3 word address

try:
    # Check if fields exist in both feature classes before proceeding
    sourceFields = [f.name for f in arcpy.ListFields(sourceFc)]
    geocodeFields = [f.name for f in arcpy.ListFields(geocodeFc)]
    
    if idFld not in sourceFields or w3wFld not in sourceFields:
        raise ValueError(f"Field '{idFld}' or '{w3wFld}' not found in source layer.")
    
    if idFld not in geocodeFields or reverseFld not in geocodeFields:
        raise ValueError(f"Field '{idFld}' or '{reverseFld}' not found in reverse geocode layer.")

    # Create a dictionary from the reverse geocoded data to map IDs to 3 word addresses
    valueDi = dict((key, val) for key, val in arcpy.da.SearchCursor(geocodeFc, [idFld, reverseFld]))

    # Open an UpdateCursor on the source layer to update the what3words field
    with arcpy.da.UpdateCursor(sourceFc, [w3wFld, idFld]) as cursor:
        for row in cursor:
            key = row[1]  # Extract the ID field from the current row
            if key in valueDi:
                row[0] = valueDi[key]  # Update the what3words field with the corresponding 3 word address
                cursor.updateRow(row)

    print("Update completed successfully.")

except arcpy.ExecuteError:
    # Catch and report any ArcPy-specific errors
    print(f"ArcPy error occurred: {arcpy.GetMessages()}")

except Exception as e:
    # Catch any other errors
    print(f"An error occurred: {str(e)}")

finally:
    # Clean up cursors if they were not properly closed
    if 'cursor' in locals():
        del cursor
Copied
GISUse 3 word addresses within a GISArcGIS

Related tutorials