Sorry, the title may be a hard way of conveying what I am looking for. I am not sure if python is the best way to do this (if not please let me know). Currently I have a custom script that does most of this but we are moving all of our production to one of the enterprise servers so things need to change. We have a list of employees that include their addresses (keep in mind that people move so that is an issue). We get this list weekly, in an effort to not use all my credits, I created a locator so that saves us credits. It seems like a simple workflow (get list, geocode, upload to enterprise) but it is not straightforward at all. The list usually has minor changes with mostly being new hires and any moving. Here is basically what I do:
1- geocode with local locator.
2- clean up USER_ (annoying results from geocoding) and delete mystery fields that show up.
3-select the unmatched and export them.
4-delete fields that were added from geocoding.
5- delete the unmatched from original so I can append back when matched.
6-geocode the unmatched with esri geocoder
7-append the newly esri geocoded matched with the geocoded from locator.
separate script 1 :send newly geocoded to locator to keep this for future geocoding.
separate script 2:
1- Delete the feature layer items with the following:
flayers = feature_layer_item.layers
flayer = flayers[0]
max_objid = flayer.query(out_statistics=[{"statisticType":"MAX","onStatisticField":"objectid","outStatisticFieldName":"MAX_OBJ"}], return_geometry=False)
maxoid = max_objid.features[0].attributes['MAX_OBJ']
i = 0
step = 20000
while i <= maxoid:
i += step
flayer.delete_features(where=f"objectid <= {i}")
This method was the fastest method to delete the features. Everything else took forever.
2- Use append to add the geocoded features to the empty layer. The norm is 90k features but it takes 1-2 hours is that normal?
My questions in addition to those asked is if there is a better way to handle this? Either by python or something else? I am assuming python is the answer since it involves geocoding and uploading to enterprise but not sure if there are other options with esri.