my question is similar to this one: https://community.esri.com/message/459758?commentID=459758#comment-459758?q=accessing%20address%20locator%20properties%2…
I am using Desktop 10.5.1
I am automating the process of creating an address locator with arcpy. Everything works fine however I need to adjust the properties of the locator after its created under the "geocode options" menu I need to change the values for the "match without house number" and "match with no zones" both need to be set to value "Yes"
How can I access this via arcpy?
this is across post on stack exchange as well: geocoding - arcmap 10.5.1 address locator properties via arcpy - Geographic Information Systems Stack Exchange
Hi
There isn't any direct property access via ArcPy but you can do what you want by editing (in code) the .loc file component of the locator (or each .loc file in a composite locator, being careful that the locator supports house numbers and zones in the first place).
Edit or insert lines so that you have the below lines in the .loc file(s):
supportsEmptyHouseNumber = truesupportsOptionalZone = true
thanks for the Info Bruce, there is an issue though. the .loc file does not contain these fields originally. You have to manually enable them within arcmap/catalog then the .loc file will append those values. I tried using the code below directly after creating the locator (no errors) but it cannot replace the false with true values because they are not inside the .loc file after being created. if you create a locator open the .loc file you wil see none of the extended properties are present. if you set them inside catalog then open the .loc file you will see they are present.
with open(r"Y:\path\to\locator.loc", 'r') as file : filedata = file.read()# Replace the target stringfiledata1 = filedata.replace("supportsEmptyHouseNumber = false", "supportsEmptyHouseNumber = true")filedata2 = filedata.replace("supportsOptionalZone = false", "supportsOptionalZone = true")# Write the file out againwith open(r"Y:\path\to\locator.loc", 'w') as file: file.write(filedata1) file.write(filedata2)
with open(r"Y:\path\to\locator.loc", 'r') as file : filedata = file.read()
# Replace the target stringfiledata1 = filedata.replace("supportsEmptyHouseNumber = false", "supportsEmptyHouseNumber = true")
filedata2 = filedata.replace("supportsOptionalZone = false", "supportsOptionalZone = true")
# Write the file out againwith open(r"Y:\path\to\locator.loc", 'w') as file: file.write(filedata1) file.write(filedata2)
I should also mention I tried the append() method to just add those lines to the .loc file but this breaks the locator.
another update... the append methods worked I just needed to add a extra line before adding the string values the code below did this correctly
with open(locatorLW, 'r') as file : filedata = file.read()filedata1 = "supportsEmptyHouseNumber = true \n"filedata2 = "supportsOptionalZone = true"# Write the file out againwith open(locatorLW, 'a') as file: file.write('\n') file.write(filedata1) file.write(filedata2) file.close()
with open(locatorLW, 'r') as file : filedata = file.read()
filedata1 = "supportsEmptyHouseNumber = true \n"
filedata2 = "supportsOptionalZone = true"
# Write the file out againwith open(locatorLW, 'a') as file: file.write('\n') file.write(filedata1) file.write(filedata2) file.close()
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.