Description
Parse a GeometryCollection object and recursively traverse its geometries arrays with a depth guard of 32.
GeoJSON collections can contain multiple members and nested geometry collections. Direct-member counts, leaf-geometry counts, and position totals are different traversals; empty containers and null geometry also represent different states.
Parse a GeometryCollection object and recursively traverse its geometries arrays with a depth guard of 32.
When to use this tool
Use Geometrycollection Leaf Count when you need a collection-shape, count, or nesting diagnostic.
How to use the tool and how it works
- Enter geometryJson. Use the units and conventions below.
- Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
- Read leafCount, collectionCount. Use the output convention below.
Parse a GeometryCollection object and recursively traverse its geometries arrays with a depth guard of 32. Count each collection including the root and each recognized noncollection geometry as one leaf.1
| Input field | Meaning and units | Accepted input |
|---|---|---|
| geometryJson | Geometry Json | Required. Text; maximum UTF-16 length 8192. |
| Output field | Interpretation | Returned shape |
|---|---|---|
| leafCount | Number of recognized noncollection geometry objects, not positions or MultiPoint children. | Required. Safe integer. |
| collectionCount | Collection Count | Required. Safe integer. |
{
"input": {
"geometryJson": "{\"type\":\"GeometryCollection\",\"geometries\":[{\"type\":\"Point\",\"coordinates\":[0,0]},{\"type\":\"GeometryCollection\",\"geometries\":[{\"type\":\"LineString\",\"coordinates\":[[0,0],[1,1]]}]}]}"
},
"output": {
"leafCount": 2,
"collectionCount": 2
}
} Limitations and assumptions
- Coordinates of leaf objects are not validated and a MultiPoint is one leaf rather than one per point; input parsing budgets also apply, with no topology or complete GeoJSON validity established.
- Inputs must satisfy both the field types and the cross-field conditions above. Invalid input causes an error; a successful false flag or documented placeholder is a different result.
Alternative or Complementary methods
Traverse and validate the full object when complete coordinate validity matters. Choose explicitly whether aggregation counts direct members, nested geometry leaves, or coordinate occurrences.
References
Similar or alternative tools
- Feature Position Total Count
Return zero and the null flag for null geometry; otherwise recursively traverse recognized geometry types and collection children to depth 32, counting each finite numeric position with at least two ordinates.
- Feature Geometry Collection Member Count
For null geometry return zero with the null flag; otherwise require GeometryCollection with an array geometries member and count its direct members.