Select to view content in your preferred language

Arcade Vertices Count for Polygons with Curves

456
4
Jump to solution
07-25-2024 02:27 PM
cquick2
New Contributor

I have an arcade question. Essentially, I want each of my land parcels to have the number of vertices labeled on them. It works for the vast majority of parcels, but not those with curves. This is easily reproduceable by creating a basic polygon and one with curves. This is the expression I am using:

 

 

var geom = Geometry($feature);
if(TypeOf(geom) == "Polygon") {
   var numVertex = Count(geom.rings[0]);
return numVertex-1;
}

 

 

 

cquick2_0-1721941170952.png

With the polygon on the right, it is clear that there are 8 vertices and the expression returns the correct result. On the left parcel, there are 7 vertices, but the expression returns 46. My guess is that the additional vertices do exist and are used to draw smooth curves, but are usually hidden from the user. I need an expression that returns the correct number of vertices (i.e. the count matches the number of vertices identified using the Feature Vertices to Points tool*) even on parcels with curves. Obviously this would be easier if Arcade had a vertex count function but it doesn't appear to.

* it also would match the !GEOM!.pointcount expression in Python

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
jcarlson
MVP Esteemed Contributor

Be aware that geometry functions in Arcade can be dependent upon the rendered geometry. The web viewer does not render true curves, so the shape being accessed will have densified curves.

To see this in action, have your polygon labels include the shape's area, perimeter, and vertex count. As you zoom in and out, the numbers change!

- Josh Carlson
Kendall County GIS

View solution in original post

4 Replies
jcarlson
MVP Esteemed Contributor

Be aware that geometry functions in Arcade can be dependent upon the rendered geometry. The web viewer does not render true curves, so the shape being accessed will have densified curves.

To see this in action, have your polygon labels include the shape's area, perimeter, and vertex count. As you zoom in and out, the numbers change!

- Josh Carlson
Kendall County GIS
cquick2
New Contributor

Thank you Josh. I will give up on using Arcade to calculate the number of vertices. We can get by with just labelling the number of vertices on the polygon (calculated with Python). I was just hoping to use attribute rules to keep a calculated and thus always updated field within the feature class, but it is not essential.

0 Kudos
jcarlson
MVP Esteemed Contributor

Is the layer in an Enterprise GeoDatabase? You could use spatial SQL in a database trigger, maybe. It depends on your RDBMS, but PostGIS, for example, has a ST_NPoints function that just directly gives you the vertex count for an input geometry.

- Josh Carlson
Kendall County GIS
0 Kudos
Bud
by
Esteemed Contributor

If I remember correctly, SDE.ST_GEOMETRY automatically densifies as well, just like Arcade does. So that might not help much. Vince, in the Data Management community, could likely shed light on how ST_GEOMETRY vertices are stored -- in the "CAD BLOB," which is separate from the true vertex count.

0 Kudos