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;
}
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
Solved! Go to Solution.
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!
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!
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.
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.
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.