Looking to create a geo-processing service tool to check a Single Address

299
2
12-20-2023 03:11 PM
Labels (1)
JoseSanchez
Occasional Contributor III

Hello everyone,

Looking to create a geo-processing  service to check (geocode) a Single Address entered as parameter, then the next step is an intersect to check if the address (point) falls inside a specific service area. The code will be in Python

Any sample code available for geocoding an address passed as parameter?

Thanks

 

2 Replies
CQuick
by
New Contributor II

Hi Jose, here is an example of how you could do the geocoding if you want to use ESRI's Geocoder which uses credits. You start by creating a string parameter in a script tool paired with the following code. Once you have the geocoding result point (geocodedAddress), you can program your service area check.

 

CQuick_0-1703547143735.png

 

import arcpy
addressToGeocode = arcpy.GetParameterAsText(0)
arcpy.management.CreateTable(arcpy.env.scratchWorkspace, "AddressTable")
arcpy.management.AddField("AddressTable", "Address", "TEXT")
with arcpy.da.InsertCursor('AddressTable', ["Address"]) as icursor:
    icursor.insertRow([addressToGeocode])
field_map = "Address Address"
locator = "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/ArcGIS World Geocoding Service"
arcpy.geocoding.GeocodeAddresses("AddressTable", locator, field_map, "geocodedAddress")

 

0 Kudos
JoseSanchez
Occasional Contributor III
0 Kudos