Creating the Aggregate Crimes tool
The
Aggregate Crimes tool will aggregate the crimes to a polygon layer, such as census block groups or police precinct boundaries. This tool will use the existing SpatialJoin
tool found in the Analysis Tools toolbox to summarize the total number of crimes in each polygon. Two polygon feature classes have been provided for you: Seattle_BG
and Seattle_Merge_Precincts
. The former contains census block groups for Seattle, while the later contains police precincts for Seattle. Both datasets are in the C:\ArcGIS_Blueprint_Python\data\crime
folder. The Aggregate Crimes tool will prompt the user to select a polygon layer, crime dataset, and output feature class; it will then perform a spatial join:
- Open
C:\ArcGIS_Blueprint_Python\ch4\SeattleCrimes.mxd
in ArcMap. - Duplicate the code that you have already created for the
ImportRecords
class by copying and pasting this class into the sameCrimeAnalysis.pyt
file. - Rename the duplicated
ImportRecords
class as AggregateCrimes...