Geocode Addresses Runs Fine in Pro But Fails With arcpy

483
3
01-25-2022 11:33 AM
MichaelMorisette
New Contributor III

Hello

I've been attempting to automate geocoding our address points to our street centerlines to tie some of the attribution together.

I have Geocoder setup that works fine in Pro (screenshot of it successfully running attached), but crashes when called via a Python script using the same parameters and running on the same machine.  Any thoughts as to why I'm getting this behavior?

I'm running ArcGIS Pro 2.8.2.

Here is the code:

 

 

from arcpy.geocoding import GeocodeAddresses
field_map = "'FULLADD' SingleLine VISIBLE NONE"
GeocodeAddresses(f"{GDB_PATH}/AddressToGeocode3",
                 ADDR_LOC,
                 field_map,
                 f"{GDB_PATH}/AddressToGeocode3_GeocodeAdd8")

 

 

GDB_PATH is the same path used by my Pro project

ADDR_LOC is the same locator path used in the Pro project

Here is the error message returned:

 

Traceback (most recent call last):
  File "<pyshell#8>", line 4, in <module>
    r"G:\GIS2\Staff\MikeM\Projects\SDE Maintenance\SDE Maintenance.gdb\AddressToGeocode3_GeocodeAdd8")
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geocoding.py", line 519, in GeocodeAddresses
    raise e
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geocoding.py", line 516, in GeocodeAddresses
    retval = convertArcObjectToPythonObject(gp.GeocodeAddresses_geocoding(*gp_fixargs((in_table, address_locator, in_address_fields, out_feature_class, out_relationship_type, country, location_type, category, output_fields), True)))
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 512, in <lambda>
    return lambda *args: val(*gp_fixargs(args, True))
arcgisscripting.ExecuteError: ERROR 000010: Geocode addresses failed.
Failed to execute (GeocodeAddresses).

 

0 Kudos
3 Replies
JayantaPoddar
MVP Esteemed Contributor

Check if a similar script works for you? Please define full pathnames, wherever required.

 

import arcpy

arcpy.env.workspace = r"C:\Geocoding\locator\addresses.gdb" #Path of default geodatabase where the table and output FC is stored

# Set local variables
table = "AddressToGeocode3"
locator = r"C:\Geocoding\locator\AddressToCenterline.loc" #Full pathname of locator
field_map = "'FULLADD' SingleLine VISIBLE NONE"
geocode_result = "AddressToGeocode3_GeocodeAdd7"

arcpy.GeocodeAddresses_geocoding(table, locator, 
                                 field_map, geocode_result)

 

I assume the locator file is saved in a basic folder, in which case you could define the full pathname of the locator file.



Think Location
0 Kudos
MichaelVolz
Esteemed Contributor

Can you try adding print statements to see if your variables for paths are populating correctly?

0 Kudos
DanPatterson
MVP Esteemed Contributor

For what its worth don't mix f-strings with unix path formation, use rf-strings to make sure you get the correct path formation.

gdb_path = r"G:\GIS2\Staff\MikeM\Projects\SDE Maintenance\SDE Maintenance.gdb"
z = f"{gdb_path}/AddressToGeocode3"
z1 = f"{gdb_path}/AddressToGeocode3_GeocodeAdd8"

z
'G:\\GIS2\\Staff\\MikeM\\Projects\\SDE Maintenance\\SDE Maintenance.gdb/AddressToGeocode3'
z1
'G:\\GIS2\\Staff\\MikeM\\Projects\\SDE Maintenance\\SDE Maintenance.gdb/AddressToGeocode3_GeocodeAdd8'

z = rf"{gdb_path}\AddressToGeocode3"
z1 = rf"{gdb_path}\AddressToGeocode3_GeocodeAdd8"

z
'G:\\GIS2\\Staff\\MikeM\\Projects\\SDE Maintenance\\SDE Maintenance.gdb\\AddressToGeocode3'
z1
'G:\\GIS2\\Staff\\MikeM\\Projects\\SDE Maintenance\\SDE Maintenance.gdb\\AddressToGeocode3_GeocodeAdd8'

 


... sort of retired...
0 Kudos