NiVO / BY TECHNOGISGermany · Indonesia
Inventory structure tutorial

GeoJSON GeometryCollection vs FeatureCollection: Name the Count Before Reviewing a Drone Inventory

Compare immediate Feature and Geometry members on a constructed GeoJSON example, preserving one record with two geometry parts without flattening it into invented assets.

GeoJSON GeometryCollection vs FeatureCollection: Name the Count Before Reviewing a Drone Inventory

Identify what the collection actually contains

A drone inventory report can show one record while a geometry inspection reports two parts. That difference does not necessarily mean a record disappeared or a duplicate asset was created. GeoJSON has distinct containers for Features and Geometries, and their member counts answer different structural questions. Before comparing totals from two tools, preserve the original object and identify the type, member array, and level of nesting behind each number. A label such as collection count is too vague to establish a common comparison.

This tutorial uses one invented Feature whose geometry contains a Point and a LineString. It compares the immediate members of the surrounding FeatureCollection with those of its GeometryCollection. It does not inspect a customer register, establish an actual location, or describe a NiVO export schema. The catalogue photograph supplies separate product context. The local function reads a shallow structural profile without flattening, rewriting, or spatially validating the example. Its output explains counted units, not the number of physical assets surveyed or inspections completed.

Read the two container definitions together

RFC 7946 defines a FeatureCollection through its features array, whose elements are Feature objects. A GeometryCollection instead uses a geometries array of Geometry objects and is itself a Geometry. Both arrays may be empty. A Feature has its own geometry and properties members; its geometry can therefore be a GeometryCollection without turning each contained geometry into a separate Feature. These are structural relationships. The application still needs its actual inventory meaning and identifier policy before interpreting any record count as an asset count.

In the constructed example, the FeatureCollection has one immediate Feature member. Inside that Feature, the GeometryCollection has two immediate Geometry members: one Point and one LineString. Reporting one and two is consistent when each result names its container and counted unit. Renaming geometries to features would not create valid Feature records with their required structure or establish two asset identities. Preserve the original record boundary and explain the relationship rather than editing the data to make two unexplained totals agree.

NiVO VTOL V7 with a white fuselage, lift rotors, and yellow wing tips
NiVO VTOL V7 with a white fuselage, lift rotors, and yellow wing tips.Source: NiVO / TechnoGIS catalogue materials supplied by the site owner · Catalogue photo
Product context only; this photograph does not depict the constructed examples in this article.

Inspect immediate members with a deliberately shallow reader

Run the following Python function locally on already decoded dictionaries. It accepts only the two named collection types, requires the corresponding list, and limits that list to sixteen members for the exercise. It rejects conflicting defining members on the collection itself and checks each immediate child type. These are a bounded set of structural checks, not a full GeoJSON validator. The function does not parse a file, recurse into child objects, inspect coordinates, validate Feature properties, or decide whether a Geometry can be drawn.

The result names the collection type, the array examined, the immediate count, and child types in their original order. A FeatureCollection result therefore never labels its count geometry parts, and a GeometryCollection result never labels its count assets. The input remains unchanged. The example calls the same function on two different container objects to make the nesting level visible. A caller should retain those object locations beside the summaries instead of displaying two bare numbers with the same generic heading.

def inspect_collection_container(obj):
    if type(obj) is not dict:
        raise ValueError("Expected a decoded collection object")
    geometry_types = {"Point", "MultiPoint", "LineString", "MultiLineString",
                      "Polygon", "MultiPolygon", "GeometryCollection"}
    kind = obj.get("type")
    if kind == "FeatureCollection":
        member, allowed = "features", {"Feature"}
        forbidden = {"coordinates", "geometries", "geometry", "properties"}
    elif kind == "GeometryCollection":
        member, allowed = "geometries", geometry_types
        forbidden = {"coordinates", "features", "geometry", "properties"}
    else:
        raise ValueError("Expected FeatureCollection or GeometryCollection")
    if forbidden.intersection(obj):
        raise ValueError("Conflicting defining collection members")
    children = obj.get(member)
    if type(children) is not list or len(children) > 16:
        raise ValueError("Expected a short immediate-member array")
    types = []
    for child in children:
        child_type = child.get("type") if type(child) is dict else None
        if type(child_type) is not str or child_type not in allowed:
            raise ValueError("Unexpected immediate child type")
        types.append(child["type"])
    return {"collection_type": kind, "counted_member": member,
            "immediate_count": len(children), "child_types": types}

# Constructed objects; the reader does not validate coordinates or Feature contents.
parts = {"type": "GeometryCollection", "geometries": [
    {"type": "Point", "coordinates": [110.0, -7.0]},
    {"type": "LineString", "coordinates": [[110.0, -7.0], [110.001, -7.001]]}]}
records = {"type": "FeatureCollection", "features": [
    {"type": "Feature", "id": "teaching-A", "properties": {"purpose": "constructed"},
     "geometry": parts}]}
print(inspect_collection_container(records))
print(inspect_collection_container(parts))

Test empty, mixed, repeated, and nested structures explicitly

Test an empty features array and an empty geometries array independently. Both should produce an immediate count of zero under their own member labels. Then test a mixed geometry collection, a Feature mistakenly inserted among geometries, a Geometry mistakenly inserted among features, and a missing or incorrectly typed member array. A tuple may look like a list to Python code, but it is outside this decoded-JSON teaching profile. Reject it rather than silently accepting a second representation contract.

Repeat the same immediate child twice and confirm that the summary reports two entries in their original order. This does not establish two distinct objects in the real world; it only preserves the supplied structure. Also include a nested GeometryCollection and observe that the shallow reader reports that child type without counting its descendants. The RFC recommends avoiding nested GeometryCollections for interoperability, but a shallow count must not quietly recurse or manufacture a flattening policy. Record the nesting question separately for the actual receiving workflow.

Keep record identity and spatial validation outside the summary

A child type check cannot establish that a Feature contains valid properties or a usable geometry. Likewise, a Point label alone cannot prove that its coordinates have the correct shape or meaning. The function deliberately leaves those questions unresolved and its result must not be called valid locations. Retain any identifier and attributes with the original Feature, then use appropriate independent checks for complete GeoJSON structure, coordinate interpretation, geometry validity, and the requirements of the intended map or inventory operation.

Flattening one GeometryCollection into several Features would be a data-model change. Someone would need to decide how the original identifier, properties, and relationship between parts are represented in the output. This tutorial performs no such transformation. A point and a line can be parts of one recorded thing without being two separately identified assets. Conversely, one Feature is not universal proof of one physical asset. The project definitions, observation model, and identity evidence must supply that meaning rather than a container count.

When two receiving tools display different totals, retain their actual operations as well as the source object. One may count Features, another immediate geometry parts, and another rendered objects after applying its own filters. Do not infer that all three counts describe the same population. A reproducible comparison records the container path, selection, nesting policy, and treatment of unlocated or unsupported content. These details help locate a disagreement without rewriting the unchanged exchange merely to produce a preferred number.

Deliver named counts with their original record boundaries

For an actual handoff, retain the unchanged file identity, decoder version, selected object path, collection type, inspected array, immediate child types and count, record identifiers, and any separate validation results. Include a small independently checked example showing one Feature with several geometry parts. If a receiving application requires a different structure, document that requirement and the authorized mapping before transforming the data. Preserve the original exchange so a later reviewer can distinguish structural inspection from an intentional change in the inventory model.

In a NiVO-related inventory discussion, this method explains how one Feature and two Geometry members can both be correct descriptions of the same constructed nesting. It makes no claim about actual asset locations, project completeness, customer deliveries, or product behavior. The useful outcome is a precise comparison whose counted units and record boundaries remain visible, leaving the independent identity and spatial checks required by the real task available instead of hiding them behind a single unexplained collection total.

Technical references

  1. RFC 7946: GeometryCollection, Feature, and FeatureCollection definitions ↗
  2. RFC 7946: defining members retain their type-specific meaning ↗
← All articles

Related articles

All articles ↗
LET’S TAKE FLIGHT

Your next mission
starts with a conversation.

Talk to our team