Schedule Calculate Prediction Zone tool

The prediction zones can be updated on a daily, weekly, or monthly recurring basis. This is especially useful in situations where daily prediction zones will be used to direct focused patrolling efforts. The Calculate Prediction Zone tool can be executed from Windows Task Scheduler on a defined schedule, and can be used to update either a local feature class, or a web layer in ArcGIS Online or ArcGIS Enterprise.

Use the following workflows to automate your prediction zones:

The input parameters specified in the tool can be configured as a script to automate the process in Windows Task Scheduler. Then the script can be triggered to execute on a reoccurring date and time using the parameters.

Appending prediction zones to an existing feature class

To configure the script to execute, run the Calculate Prediction Zones tool to append daily, weekly, or monthly prediction zones to an existing feature class complete the following steps.

  1. Open the Catalog Pane, click the View tab then the Catalog button.
  2. In the Catalog Pane, right-click on the toolboxes folder and choose New toolbox.
  3. Name the new toolbox ScheduledTools.tbx and click Save.
  4. In the Catalog Pane, right-click on the ScheduledTools.tbx you created.
  5. Choose New > Model, click on ScheduledTools.tbx to expand and rename model to SchedulePredictionZones.
  6. Right-click on the SchedulePredictionZones model, and choose Edit.
  7. Choose Calculate Prediction Zones from the Crime Analysis ribbon, under the Repeat and Near Repeat menu.
  8. Choose the parameters you would like to be added to an existing feature class.
  9. Click on the SchedulePredictionZones model tab in ArcGIS Pro, to open the model for editing.
  10. In the Catalog Pane, click on the History tab, drag the Calculate Prediction Zones result into the SchedulePredictionZones model.
  11. Click on the Analysis tab then, click the Tools button, to open the geoprocessing pane.
  12. In the search dialog, search for the Append tool.
  13. Drag the Append tool, into SchedulePredictionZones model.
  14. Drag a connector line from Output Feature Class Zones to the Append tool, and choose Input Datasets.
  15. Double-click the Append tool in the model to open the tool parameters. The Input Datasets parameter will be populated with the output feature class zones.
  16. Set the Target Dataset to the feature class you wish to append calculate prediction zones results to.
  17. Set the Schema Type to Input schema match target schema, if the schema matches.
  18. Click OK to run the tool and verify that the data updated successfully.

Overwriting a prediction zone web layer

To configure the script to execute, run a custom script to overwrite daily, weekly, or monthly prediction zones to an web layer complete the following steps.

  1. Open the Catalog Pane, click the View tab then the Catalog button.
  2. In the Catalog Pane, right-click on the toolboxes folder and choose New toolbox.
  3. Name the new toolbox ScheduledTools.tbx and click Save.
  4. In the Catalog Pane, right-click on the ScheduledTools.tbx you created.
  5. Choose New > Model, click on ScheduledTools.tbx to expand and rename model to SchedulePredictionZones.
  6. Right-click on the SchedulePredictionZones model, and choose Edit.
  7. Choose Calculate Prediction Zones from the Crime Analysis ribbon, under the Repeat and Near Repeat menu.
  8. Choose the parameters you would like to be added to an existing feature class.
  9. Click on the SchedulePredictionZones model tab in ArcGIS Pro, to open the model for editing.
  10. In the Catalog Pane, click on the History tab, drag the Calculate Prediction Zones result into the SchedulePredictionZones model.
  11. Click on the Analysis tab then, click the Tools button, to open the geoprocessing pane.
  12. In the search dialog, search for the Append tool.
  13. Drag the Append tool, into SchedulePredictionZones model.
  14. Drag a connector line from Output Feature Class Zones to the Append tool, and choose Input Datasets.
  15. Double-click the Append tool in the model to open the tool parameters. The Input Datasets parameter will be populated with the output feature class zones.
  16. Set the Target Dataset to the feature class you wish to append calculate prediction zones results.
  17. Set the Schema Type to Input schema match target schema, if the schema matches.
  18. Click OK.
  19. Click on the Analysis tab then, click the Tools button, to open the geoprocessing pane.
  20. In the search dialog, search for the Delete Features tool.
  21. Drag the Delete Features tool, into SchedulePredictionZones model.
  22. In the search dialog, search for the Append tool.
  23. Drag a second Append tool, into SchedulePredictionZones model.
  24. Double-click the Delete Features tool in the model to open the tool parameters.
  25. The Input Feature parameter will be populated with the prediction zones web layer. Browse to the web layer you wish to update and delete features.
  26. Drag a connector line from the output feature class of the Delete Features tool to the second Append tool, and choose Target Datasets in the menu that appears.
  27. Drag a connector line from the output feature class of the Calculate Prediction Zones tool to the second Append tool, and choose Input Datasets in the menu that appears.
  28. Double-click the second Append tool in the model to open the tool parameters.
  29. Set the Schema Type to Input schema match target schema, if the schema matches.
  30. Click OK.
  31. Close the SchedulePredictionZones model, and choose Save your changes.
  32. In the Catalog Pane, click on the toolboxes folder ScheduledTools.tbx to expand the SchedulePredictionZones model.
  33. Double-click SchedulePredictionZones model and click OK to run the tool.
  34. Go to the calculate prediction zones web layer and verify that the data updated successfully.

Create a script to use in task scheduler

Use a text editor to create a script to run in task scheduler.

  1. In the same folder as your ScheduledTools.tbx create a script file called update_prediction_zones.py.
  2. Open the update_prediction_zones.py in a text editor.
  3. Copy and paste the code block below, into the text editor.
        
    import arcpy
    
    arcpy.ImportToolbox("C:\\locationoftoolbox\\ScheduledTools.tbx")
    
    arcpy.ScheduledTools.SchedulePredictionZones()
    
    
  4. Update the example path, "C:\\locationoftoolbox\\ScheduledTools.tbx" to the path location of your ScheduledTools.tbx
  5. Save the update_prediction_zones.py file and close.

Set up the task scheduler

Use Windows Task Scheduler to create a task to update your prediction on a specific schedule. By scheduling this tool the prediction zones layer will be updated.

  1. Open the Task Scheduler on the computer that is hosting the tools.
  2. Click Action > Create Task and name your task.
  3. Click the Actions tab and click New.
  4. Set Action to Start a Program.
  5. Browse to the location of your Python installation (for example, C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe).
  6. In the Add arguments text box, copy the name of the script (update_prediction_zones.py).
  7. In the Start in text box, type the path to the folder where your script is and click OK.
  8. Click the Trigger tab, click New, and set a schedule for your task.
  9. Click OK.
Top