HOW TO

Calculate polygon vertices in the ArcGIS Enterprise portal and ArcGIS Online

Last Published: September 6, 2024

Summary

In spatial analysis, understanding the geometry of polygons is crucial for accurate data interpretation and decision-making. Calculating the number of vertices in a polygon is a fundamental task that enhances the precision of geographic analyses. When creating a freehand polygon, the number of vertices can far exceed that of a standard polygon. This is due to the continuous and detailed nature of freehand drawing, which captures every subtle curve and movement as a vertex. This can also be useful in determining whether polygons are standard or freehand.

This article provides the workflow to calculate polygon vertices in the ArcGIS Enterprise portal and ArcGIS Online.

Procedure

  1. Log in to the ArcGIS Enterprise portal or ArcGIS Online and click Content > My Content.
  2. Click the hosted feature layer to open the item details page.
  3. Add a new field. Refer to Portal for ArcGIS: Add a field or ArcGIS Online: Add a field for instructions. In this example, a new field, ‘Vertices’, is added to the attribute table.
  4. Calculate the field values to generate the count of vertices using Arcade. Refer to Portal for ArcGIS: Calculate values for a field or ArcGIS Online: Calculate values for a field from the item page for instructions.
  5. In the Expression box, specify the following Arcade expression:
    1. Get the geometry of the polygon.
var geometry = Geometry($feature);
  1. Get the rings (boundaries) of the polygon.
var rings = geometry.rings;
  1. Initialize a counter for the number of vertices.
var vertexCount = 0;
  1. Loop through each ring in the polygon.
for (var i in rings) {
    vertexCount += Count(rings[i]);
}
  1. Return the total number of vertices.
return vertexCount;

The code block below shows an example of the full working script.

var geometry = Geometry($feature);

var rings = geometry.rings;

var vertexCount = 0;

for (var i in rings) {
    vertexCount += Count(rings[i]);
}

return vertexCount;
  1. Click OK.

The image below shows the count of vertices of each polygon generated in the attribute table.

The count of vertices in a polygon generated in the attribute table

Article ID: 000033400

Software:
  • ArcGIS Online
  • 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

Related Information

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options