Haven't been able to get passed the create locator tool for the mmpk. I'm looking to set up a locator with one of the layers (a road layer) but whenever I run the script, I get this error:
Error creating locator: Failed to execute. Parameters are not valid.
ERROR 002790: Every Table requires a Role.
I'd appreciate any insights I can get on this. Thank you!
# List of data source URLs
]
# Open Pro Project
aprx = arcpy.mp.ArcGISProject(r"pathToProject")
# Create a new disposable map
map = aprx.createMap("MMPK", "MAP")
print(map.name, "has been added")
# Get rid of basemap layer from map
basemap = map.listLayers()
for i in basemap:
print(i.name, "is an active layer")
if i.name == "Topographic":
map.removeLayer(i)
# Add Data Layers from Server to map
layers = []
for data in serverData:
try:
layer = map.addDataFromPath(data)
layers.append(layer)
print(f"Added layer from {data}")
except Exception as e:
print(f"Error adding layer from {data}: {e}")
# Create Locator
lang = "ENG"
output = r"saveLocatorPath"
road_layer = layers[1]
fieldMap = "StreetAddress.HOUSE_NUMBER_FROM_LEFT",road_layer,".L_LADD",\
"StreetAddress.HOUSE_NUMBER_TO_LEFT",road_layer,".L_HADD",\
"StreetAddress.HOUSE_NUMBER_FROM_RIGHT",road_layer,".R_LADD",\
"StreetAddress.HOUSE_NUMBER_TO_RIGHT",road_layer,".R_HADD",\
"StreetAddress.HOUSE_NUMBER_FROM_RIGHT",road_layer,".R_LADD",\
"StreetAddress.PARITY_LEFT",road_layer,".L_PARITY",\
"StreetAddress.PARITY_RIGHT",road_layer,".R_PARITY",\
"StreetAddress.STREET_NAME",road_layer,".NAME",\
"StreetAddress.STREET_SUFFIX_TYPE",road_layer,".SFX",\
"StreetAddress.STREET_SUFFIX_DIR",road_layer,".DIR",\
"StreetAddress.FULL_STREET_NAME",road_layer,".FULL_NAME"
refData = road_layer, "StreetAddress"
try:
arcpy.geocoding.CreateLocator(country_code="CAN", primary_reference_data=refData, field_mapping=fieldMap, out_locator=output, language_code=lang)
print("Locator created successfully.")
except Exception as e:
print(f"Error creating locator: {e}")