Sort the table
Having generated the data joining the buffers and the houses, let's now sort the data to make it easier to examine.
As we've used:
arcpy.TraffordModel_models(Burglaries, Distance, Buildings, Out)
to run the model, rather than pythonaddins.GPToolDialog()
, the code will wait while the
model runs. That means that in TraffordModelScript.py we can safely add the following lines after the
model running code:
if arcpy.Exists("crime_sorted.shp"):
arcpy.Delete_management ("crime_sorted.shp")
arcpy.Sort_management(Out, "crime_sorted", [["Join_Count", "DESCENDING"]])
This is all we need to produce another shapefile "crime_sorted.shp" containing the sorted data. Note that this won't yet be added to the map, but you can find it using ArcCatalog. Notice that we, again, clean up the files just incase the tool has been run before.
Once you've got that working, go onto the final part, where we'll get the map displaying.