Is it possible to geocode a table using the Esri World Geocoder in a stand alone script using Pro and the function arcpy.GeocodeAddresses_geocoding?
If I'm in Pro and use this tool, and use the Esri World Geocoder we have as an item in our Portal (with an AGO user credentials stored), I can successfully geocode the table as expected.
If I try writing a stand-alone Python script, it fails every time, and I'm really not sure what I'm doing wrong.
Below is a sample of my code:
<SPAN class="comment token"># portal variables</SPAN>
portalUrl <SPAN class="operator token">=</SPAN> <SPAN class="string token">'...our AGO for Organizations URL...'</SPAN>
portalUser <SPAN class="operator token">=</SPAN> <SPAN class="string token">'...userName...'</SPAN>
portalPassword <SPAN class="operator token">=</SPAN> <SPAN class="string token">'...userPassword...'</SPAN>
<SPAN class="comment token"># geocode variables</SPAN>
geocodeTable <SPAN class="operator token">=</SPAN> <SPAN class="string token">'...path to table containing addresses...'</SPAN>
geocodeUrl <SPAN class="operator token">=</SPAN> r<SPAN class="string token">'https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer'</SPAN>
OR
geocodeUrl <SPAN class="operator token">=</SPAN> r<SPAN class="string token">'...url to our Portal item referencing the Esri World Geocoder with AGO credentials stored...'</SPAN>
geocodeFieldMap <SPAN class="operator token">=</SPAN> <SPAN class="string token">'Address SiteAddress;City SiteCity;Region SiteState;Postal SiteZip'</SPAN>
geocodeOutput <SPAN class="operator token">=</SPAN> <SPAN class="string token">'...path to output feature class...'</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>SignInToPortal<SPAN class="punctuation token">(</SPAN>portalUrl<SPAN class="punctuation token">,</SPAN> portalUser<SPAN class="punctuation token">,</SPAN> portalPassword<SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>GeocodeAddresses_geocoding<SPAN class="punctuation token">(</SPAN>geocodeTable<SPAN class="punctuation token">,</SPAN> geocodeUrl<SPAN class="punctuation token">,</SPAN> geocodeFieldMap<SPAN class="punctuation token">,</SPAN> geocodeOutput<SPAN class="punctuation token">,</SPAN> None<SPAN class="punctuation token">,</SPAN> None<SPAN class="punctuation token">,</SPAN> None<SPAN class="punctuation token">,</SPAN> None<SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
I seem to always get this error:
arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid.<BR />ERROR 000005: Could not open the address locator.<BR />Failed to execute (GeocodeAddresses).
I have also tried using arcgis.geocoding.batch_geocode ... but this doesn't preserve any of the other attributes within the table, other than the address information used to locate the point, which is pointless for what we're trying to accomplish.