HOW TO

Count the number of point features within polygon features using ArcGIS Arcade in Map Viewer

Last Published: August 6, 2024

Summary

In ArcGIS Online and Portal for ArcGIS Map Viewer, calculating the number of point features within polygon features aids in spatial analysis and decision-making. For example, it is useful when quantifying and visualizing the distribution of points, such as incidents, facilities, or population data, within specific geographic areas. In this article, an Arcade expression is used to count the number of point features within the polygon features in Map Viewer.

Procedure

  1. In Map Viewer, click the desired hosted feature layer. On the item details page, click the Data tab.
Note:
Skip to Step 3 if the script is run on an existing field.
  1. In the Table view, create a new field. Refer to ArcGIS Online: Add a field or Portal for ArcGIS: Add a field for instructions. Ensure String or Double is selected from the Type drop-down list. In this example, a field named 'CenterCount' is created.
  2. Click the field header and select Calculate. In this example, 'CenterCount' is selected.
  3. In the Calculate Field dialog box, click Arcade.
  4. In the Arcade Calculator dialog box, specify the Expression box with the following Arcade expression. Replace <point_FeatureClass> with the intended point feature class. In this example, it is ServiceCenters.
//Define the point feature class.
var point_fc = FeaturesetByName($datastore, "<point_FeatureClass>")

//Identify the intersected point features.
var int_point = Intersects(point_fc,$feature)

//return the count of the points.
return Count(int_point)
  1. Click Test to verify the expression. Click OK to apply the query.
Arcade expression configuration.jpg

The image below demonstrates the number of point features within each polygon feature in Map Viewer.

CenterCount field displaying the number of point features within each polygon feature.jpg

Article ID: 000033148

Software:
  • ArcGIS Online
  • Portal for ArcGIS
  • ArcGIS Enterprise 11 1
  • ArcGIS Enterprise 11 3
  • ArcGIS Enterprise 11 2

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options