Count vertices to determine if shape is null

288
3
02-13-2024 11:12 AM
Status: Open
Bud
by
Notable Contributor

As @AJR mentioned in How to return null in Arcade with Calculate Field (python works fine)? :

[I want to] use an arcade expression to operate on the shape and some of the shapes are null.  There doesn't seem to be any way in arcade to detect if the shape is null before attempting to use it (i.e. intersect it with another feature class). 

...There isn't an arcade function to count the number of vertices in a shape -https://developers.arcgis.com/arcade/function-reference/geometry_functions/

using Count(Text(Geometry($feature))) returns a result when used in the field calculator (null shapes are returned as empty strings), but trying to use Count(Text(Geometry($feature))) > 0 as a null shape filter fails when used as part of an attribute rule (i.e. null shapes pass the check)

Could functionality be added to Arcade for attribute rules that lets us count vertices — so that we can determine if the shape is null?

3 Comments
AmirBar-Maor

@Bud 

FWIW I was able to run this expression as an attribute rule calculation to identify features with no vertices (empty geometry) using ArcGIS Pro 3.2.2:

if (IsEmpty(Geometry($feature))) return null;

 

PaulLeBlanc1

This function differentiates between null and empty geometries.

 

function empty_null_shape(geo) {
    return Decode(TypeOf(geo),
        "", "null",
        "Point", IIF(IsNan(geo.X), "empty point", "point"),
        "Polyline", IIF(Count(geo.paths) == 0, "empty polyline", "polyline"),
        "Polygon", IIF(Count(geo.rings) == 0, "empty polygon", "polygon"),
        "Multipoint", IIF(Count(geo.points) == 0, "empty multipoint", "multipoint"),
        "?" // Default
    )
}

 

PaulLeBlanc1_0-1707925042749.png

 

Bud
by

This idea can be closed. Misunderstanding/bad data.