NiVO / BY TECHNOGISGermany · Indonesia
Boundary structure tutorial

GeoJSON Linear Rings: Check Closure Without Silently Repairing a Drone Boundary

Inspect a constructed two-dimensional ring for minimum positions and exact closing values, while keeping structural checks separate from polygon validity and surveyed boundaries.

GeoJSON Linear Rings: Check Closure Without Silently Repairing a Drone Boundary

Identify the ring before counting boundary vertices

A GeoJSON boundary can contain a repeated coordinate at the end of its position sequence. That repetition may be required closure rather than an extra surveyed corner or an accidental duplicate. Before deleting it during a drone inventory handoff, identify the geometry type and the exact array being inspected. A Polygon contains ring arrays, while a LineString follows a different structural rule. Applying a generic duplicate-removal operation to both can change the representation without explaining whether the resulting object still meets its intended requirements.

This tutorial inspects one constructed two-dimensional ring after its coordinate array has already been selected. It does not open a project dataset, establish a real parcel boundary, calculate area, or generate a flight route. The example separates position count and closing values from broader questions of geometric validity and survey correctness. The product photograph supplies catalogue context only. A successful structural result should not be described as confirmation that a NiVO mapping delivery contains the correct legal, physical, or operational boundary.

Read the minimum length and closure requirements together

RFC 7946 describes a GeoJSON linear ring as a closed LineString with at least four positions. Its first and last positions must contain identical values, and their representations should also be identical. A constructed triangle therefore uses three corner positions followed by the first position again. Four positions do not automatically mean four distinct corners. Preserve the supplied coordinate order when making this check, because sorting or deduplicating the array would change the sequence whose closure is being examined.

The same specification describes Polygon coordinates as an array of rings, with the exterior first and any interior rings following. It also states a winding convention and a compatibility recommendation concerning parsers that encounter the other winding direction. This tutorial deliberately does not test winding, assign exterior or hole roles, or apply polygon repair. It checks the selected ring length and equality of its endpoints within a stated two-dimensional profile. Keep those limited results separate from any complete RFC conformance or geometry-engine validity report.

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 a small supplied ring without altering it

Run the following Python function locally. It accepts a list containing four through sixty-four two-coordinate lists, with numeric longitude and latitude values within the displayed profile bounds. Boolean values and unsupported dimensions are rejected. The size and dimension restrictions describe this teaching reader rather than every possible GeoJSON dataset. The function checks the original closing values and returns position count, nonclosing position slots, and distinct coordinate pairs. It does not append a missing endpoint or reorder the supplied coordinates.

The constructed triangle should report four positions, three nonclosing slots, and three distinct coordinate pairs. The two counts have different meanings: repeated internal positions can make the number of distinct pairs smaller than the nonclosing slot count. Python numeric equality allows values such as zero and zero-point-zero to compare equally, but the function does not examine their original JSON spelling. Preserve the source text if identical representation matters to the review. No file is written and no real geometry is transformed by this example.

def inspect_ring_2d(ring):
    if type(ring) is not list or not 4 <= len(ring) <= 64:
        raise ValueError("Teaching profile expects 4..64 supplied positions")
    for position in ring:
        if type(position) is not list or len(position) != 2:
            raise ValueError("Teaching profile supports two-dimensional positions")
        lon, lat = position
        if (type(lon) not in (int, float) or type(lat) not in (int, float)
                or not -180 <= lon <= 180 or not -90 <= lat <= 90):
            raise ValueError("Expected finite numeric longitude and latitude")
    if ring[0] != ring[-1]:
        raise ValueError("Supplied first and final positions must have equal values")
    return {"position_count": len(ring),
            "nonclosing_slots": len(ring) - 1,
            "distinct_pairs": len({tuple(p) for p in ring})}

# Constructed coordinate sequence, not a surveyed boundary.
triangle = [[0, 0], [1, 0], [0, 1], [0, 0]]
print(inspect_ring_2d(triangle))

Reject an open sequence before considering any correction

If the final position differs from the first, the function reports that supplied condition rather than manufacturing a closing coordinate. Appending the first position may look like a simple formatting repair, but the intended boundary still needs to be established from its source. A missing closing entry and a genuinely missing final corner are different problems. Retain the received array and the exact mismatch so that a separate reviewed correction can explain which interpretation applies and what evidence supports it.

Likewise, an apparently small coordinate difference should not be erased by a rounding tolerance hidden inside this structural check. The tutorial compares supplied numeric values exactly. A project may have a justified precision or normalization policy, but that policy belongs in an explicit transformation with before-and-after evidence. Do not infer an acceptable boundary displacement from the number of decimal places in a sample. A near-closing sequence can be useful diagnostic evidence without being accepted as the same supplied closed ring.

Keep closure separate from topology and boundary meaning

A sequence can satisfy the minimum count and closing-value check while still failing other important tests. It may repeat one point throughout, contain collinear positions, cross itself, or describe a shape unrelated to the intended mapped asset. The function does not reject all such cases because it is intentionally a structural reader, not a geometry validator. Its distinct-pair count is descriptive evidence rather than a complete validity decision. Do not turn the absence of an exception into a statement that the polygon is usable for every downstream task.

Test that limitation explicitly with four identical coordinate pairs: the function will report one distinct pair while confirming the supplied closure. Also test a closed sequence in the reverse order; this reader does not evaluate winding. These examples show what the result actually establishes and prevent a successful toy check from being overextended. A real workflow needs the appropriate checks for polygon topology, hole relationships, coordinate context, intended boundary identity, and receiving-tool behavior. None of those conclusions follows solely from repeating the initial position at the end.

Deliver the structural finding with the unchanged sequence

For a real boundary review, record the source dataset identity, selected feature and ring index, complete supplied endpoint values, position count, dimension policy, reader version, and the result or rejection diagnostic. Include a small independently checked case and retain the original sequence. If a separate correction is authorized, explain its evidence and compare the resulting geometry through the relevant project checks. Keep a record of which operations were only inspected and which were actually changed, so the diagnostic remains reproducible.

In a NiVO-related boundary handoff, this approach makes a common representation issue easier to explain without inventing a survey conclusion. Another reviewer can see why the closing position is present, why it is not an additional distinct corner, and why removing it casually can be inappropriate. Continue any required geometry validation and boundary acceptance with their own evidence. The useful outcome is a clear account of the supplied sequence and the exact structural requirement tested, with broader claims about the mapped area left to the appropriate review.

When comparing applications, check whether one reports stored positions while another reports distinct vertices or excludes the closing position from its count. Those totals can differ without proving that coordinates were lost. Compare the actual ordered pairs and the definition behind each displayed total. This tutorial exposes all three simple counts precisely so that a numerical difference in a user interface does not silently become a claim that a delivered boundary was altered.

Technical references

  1. RFC 7946 section 3.1.6: linear rings and Polygon structure ↗
  2. RFC 7946 section 3.1.1: positions and coordinate ordering ↗
← All articles

Related articles

All articles ↗
LET’S TAKE FLIGHT

Your next mission
starts with a conversation.

Talk to our team