ArcGIS Pro

Dynamic Aggregate Points within Polygon Features for Exploratory Analysis

Starting ArcGIS Pro 2.8, authoring this kind of layers is made very easy using Make Aggregation Query Layer. Please read about this in the following blog and ArcGIS Pro help:

Let’s say you have some point data representing crime data, 311 calls, tornadoes across the nation, sales, or earthquakes around the world, and you want to explore data concentration, patterns, or trends—maybe over time or maybe using different criteria as you’d do in an exploratory analysis. Simply drawing these points on a map might not help reveal any meaningful information, since most of them will overlap and obscure each other. One approach we could use to reveal meaningful information is to aggregate points within known geometry boundaries such as districts, cities, and counties etc.

We could use some geoprocessing tools to get to the same results, but they are static. If data changes or we want to use different criteria for analysis, we’d need to run those tools again. This makes sharing your geoprocessing results hard too via web.

With the approach described in this blog, we need to setup once and then start interacting with the layer or map properties to make necessary changes and view the results right away on the map.

Map on the right shows crimes total for each districts by aggregating crime locations shown on the left
Map on the right shows crimes total for each districts by aggregating crime locations shown on the left

In this blog, we will work with crime locations and learn how to aggregate them within police district boundaries to help us explore the following:

We will also learn how to setup the layer to explore pattern based on the following:

Prepare the Data

Let’s get started:

Transform Crime Locations into District Polygons

You are a geographic information system (GIS) analyst and you are tasked to produce a map for the police chief, showing districts with crime totals. You have a point feature class showing locations of all crimes occurred in the city and a polygon feature class for police districts. We will follow the steps below to create a query layer to produce such map in this section. In the following section, we will add few additional parameters to make the layer produce different results based on different inputs.

Follow the steps below to create the layer:

Note: Values in this field get computed dynamically every time you refresh the map. Therefore, when new data are added, results showing on the map gets updated in the next map refresh. You don’t need to modify or recreate the layer.

Find Out if Crimes Happen on Weekends

The above map made the police chief happy and even district commissioners found the map very helpful. Now the person in charge of crime analysis came in and asked you to help them find out whether there are correlations between crimes that occur on weekdays and those that happen on weekends. Since you chose to create a query layer in the section above, meeting the crime analyst’s needs will be easy. Let’s follow the steps below to create a crime map for different days of week:

Click the blue pencil icon to open the Edit Query Layer dialog box.

Query layer's Source tab showing SQL query

Insert the following WHERE clause with a range parameter right after the table name CRIMES:
WHERE ::r:DayOfWeekRange

SQL query with a range parameter of integer type
SQL query with a range parameter of integer type
Defining DayOfWeekRange parameter
Defining DayOfWeekRange parameter
  1. Field or Expression—Type “datepart(dw, datetime_)”.
    Note: DatePart() is a SQL Server function that extracts the day of the week from a date value. Other databases have similar functionalities, but their names and syntax may differ. If you want to find crime pattern by hour of the day, use “datepart(hh, datetime_)”
  2. Data Type—Choose Integer.
  3. Default value—Uncheck the check box.
  4. Name of the table the field belongs to—Type “Crimes”.

If you click the Range tab on the Layer Properties page now, you will see that the range settings got automatically defined. When you define a range parameter of the integer or double data type, the layer is automatically made range aware and will start honoring the map’s range slider’s settings.

The range slider appears on the right side of the map.

Have Single Value checked, and Step Interval set to 1.

Settings on the Range tab
Settings on the Range tab

On the range slider, you can navigate between different days of the week (where 1 = Sunday and 7 = Saturday). Note: This may vary based on database flavor and locale settings, etc.

Map showing weekend crimes
Map showing weekend crimes

Visualize Patterns for Specific Crime Types

The map above made the crime analyst’s job more efficient. They realized the importance of dynamic nature of this map and layer, and came back with a new requirement – produce the same map but for specific crime type instead of all crimes. Query layers are flexible enough for that too.

Insert a discrete parameter named CategoryVar in the SQL query
Insert a discrete parameter named CategoryVar in the SQL query

Note: Please make sure to have a space between “::CategoryVar” and the closing parenthesis, otherwise you will run into a bug.

Defining CategoryVar discrete parameter
Defining CategoryVar discrete parameter

Choose Query Parameters on the Layer Properties page.

Select a crime type from Query Parameters tab
Select a crime type from Query Parameters tab
Map showing crime totals for burglary/theft
Map showing crime totals for burglary/theft

Note: since you are using aggregated results for crime of specific type rather than all, the value ranges have changed. You may need to use Refresh Values on the Symbology pane.

Use the Time Slider

Months or may be years went by since you made crime analysis dynamic. It made the police and analysts more efficient and they think crime rate might have been decreasing. Now, you need to make a map to show the total number of crimes by month or year or weeks.

Name of the table the field belongs to—Type “Crimes”.

Defining a range parameter of date type
Defining a range parameter of date type

You can combine all criteria such as time span, day of week, crime type or use any combination of them to analyze and produce crime map very easily and interactively. And of course, the results are always up-to-dated with the latest crime data.

Share Your Result in Web Maps

You can share the map as a map image layer (or map service) with some limitations:

About the author

Tanu is a product engineer on Esri Mapping Team focusing on map service, print service, and ArcGIS Pro. He also works on spatio-temporal analysis, spatial aggregation and real-time data. Tanu’s background includes a masters in Urban Planning from University of Akron, Ohio, USA and a bachelor degree from Khulna University, Bangladesh, and worked as GIS Coordinator in City of West Springfield, and GIS Specialist in a hydrology modeling center in Bangladesh before joining Esri.

Notify of
Inline Feedbacks
View all comments

Next Article

Nautical chart creation is versatile with ArcGIS Maritime

Read this article