Select to view content in your preferred language

Geocoding using a publicly available geocoding service doesn't work with arcpy.geocoding.GeocodeAddresses

380
3
12-19-2024 02:57 PM
LDreyfuss
Occasional Contributor

Hello all,

I would like to run a simple python script that uses arcpy.geocoding.GeocodeAddresses to geocode an sde table and output to a feature class. I'd like to use our geocoding service, which is available to anyone on our network and is also a publicly shared item on our Portal. It's also configured as a Geocoding Utility Service. 

When I try to use the URL configured with Portal, it fails when run in Server's installation of python with an access error (ERROR 000005: Could not open the address locator.). I can run the script in Pro's installation of python, it works as long as I have an active connection to the Portal configured in Pro (I don't need to be signed in for this to work).

I can load the .loc file that's on the Server directories and by-pass the URL all together, but then I get the following error on the table when I try to run the script: ERROR 000010: Geocode addresses failed. The Fields collection did not contain an expected geometry field. Failed to execute.

This feels like it should be possible using arcpy, but I am coming up short. Server 11.3 and Pro 3.3

I've also posted in the Geoprocessing community: https://community.esri.com/t5/geoprocessing-questions/geocoding-using-a-publicly-available-geocoding...

Tags (3)
0 Kudos
3 Replies
JakeSkinner
Esri Esteemed Contributor

Hi @LDreyfuss,

Execute the Geocode Addresses GP tool in Pro.  If this is successful, click the dropdown arrow next to Run and select Copy Python Command.  Compare this to what you have in your script.  This may help you troubleshoot what's going on.

JakeSkinner_0-1734696193433.png

 

0 Kudos
LDreyfuss
Occasional Contributor

@JakeSkinner that's exactly what I did to create the script in the first place, as I wasn't sure of the syntax. Unfortunately, the URL input for a locator not included in the active Portal returns an error, even in Pro (see Toolerror.png). I thought it was a python issue exclusively, but it looks like the tool can't validate a locator via URL in Pro that's not in the active Portal. The URL that's throwing the error works when I've got the active connection set to the Portal where the locator is hosted, even if I'm not signed in (see ToolNoerror.png). So I feel like this is expected. I guess my question boils down to is there a way to configure the Locator parameter to accept a geocode service URL via REST and only acrpy?

Additionally, when I try to use the .loc file that's on the server that backs up the service, the locator validates, but it won't run the tool. It errors with any table input with the error "ERROR 000010: Geocode addresses failed.
The Fields collection did not contain an expected geometry field.
Failed to execute (GeocodeAddresses)."

A rock and a hard place feels like the appropriate metaphor.

0 Kudos
LDreyfuss
Occasional Contributor

@JakeSkinner it also looks like there's a folder with all of the cached locators that update when I switch active connections in Pro here: C:\Users\<username>\AppData\Local\ESRI\ArcGISPro\rest_locator_cache. So I guess Pro isn't accessing the locator URL so much as accessing this cache. Is that correct?

0 Kudos