Hello y'all,
Our dispatch center uses a CAD system that uses our GIS APIs to aid the dispatchers. One of the chief spatial questions that is automatically answers is what the closest available Fire unit and EMS unit to any given call is.
Recently, one of the municipalities within our county had a catastrophic hack. The hackers deleted all systems and data. Our county level dispatch center had to take all the calls. Reflecting on the incident, our communications directory over the dispatch operation, asked GIS to help solve the issue.
GIS is to create a product, that can be kept up to data, that can provide the following information for every address in the county, organized in a table, printed to a formatted PDF:
- First Closest Fire Station
- Second Closest Fire Station
- Third Closest Fire Station
- First Closest EMS Station
- Second Closest EMS Station
- Third Closest EMS Station
- ESN Zone
- Law Enforcement Zone
Before I move on to outlining the solution I am attempting to create, let me outline some of the moving elements the process will need to be resilient to. First, EMS and Fire stations can be moved, added or removed. While this is more involved for fire stations (it can still happen), it's a simple thing for the EMS stations. Some of these "EMS Stations" are not really stations but are concrete pads off a main road that an ambulance can idle on instead of driving constantly. Therefore, I cannot create the script thinking that the stations will remain consistent. Secondly, New addresses are added every day, old ones are deleted, and existing ones are moved. Thirdly, new streets are added every week. These may seem innocuous, but they have precluded me from attempting to solve this in simpler ways.
Now on to the current form of the solution. I have developed a python library that carries out this analysis using arcpy. Using varies loose terms and glossing over more details than I would like the process is as follows:
- Cleans and preps temporary workspace.
- Copies source data to a file geodatabase.
- Creates and validates a network dataset.
- Performs closest facility analysis for each address.
- Identifies containing zones for each address.
- Outputs results to Excel/PDF.
My current issue I am dealing with has to do with the attributes of the facility sublayer. I have attached a screenshot of one of them. Since the "Location OBJECTID #" mapping must be added separately, I was utilizing the append parameter of the arcpy.na.AddLocation utility to append the field mapping; filling out the Name, SourceID, and SourceOID fields with the appropriate values from the source layer so the results could be mapped back to the source values. It is from the source values that the excel/pdf is generated. However, I had to abandon this method due to the fact that the append parameter was only creating duplicate facilities as opposed to updating the existing ones. Now I am attempting to use arcpy.da.UpdateCursor and a dictionary to force the correct values in the table. But I am running into issues with that.
Do y'all have any insight into getting the append parameter to correctly function or how to get the update cursor to actually work.