NiVO / BY TECHNOGISGermany · Indonesia
Raster tile handoff

GeoPackage Tile Rows: Start at the Upper Left of the Actual Matrix

Trace tile_row and tile_column to GeoPackage matrix metadata, then calculate a constructed tile envelope without assuming a global web-map grid.

GeoPackage Tile Rows: Start at the Upper Left of the Actual Matrix

Identify the tile table before interpreting its row numbers

A tile extracted from a drone-map GeoPackage can look correct while being placed in the wrong part of a reconstructed mosaic. One possible cause is treating its row number as though it belonged to a familiar global web-map grid. Before changing image orientation or rewriting tile identifiers, identify the tile table and the metadata row for its zoom level. This tutorial calculates an envelope from constructed matrix values. It does not open a customer package or establish how a particular NiVO application exports maps. The photograph provides product context rather than evidence of the invented grid.

Begin with the accepted package revision, the producing workflow and the receiving task. A small offline reference map, a raster overview for discussion and an analytical image delivery can have different requirements. Keep the source file unchanged and record the table name beside every extracted tile identifier. A zoom number alone is insufficient context for comparing tiles from different packages. Preserve the source relationship before attempting a merge, and retain any discrepancy as a finding rather than selecting the orientation that happens to look convincing in a preview.

Read the matrix dimensions and upper-left origin

The approved GeoPackage 1.4.0 standard defines a top-left tile origin. The matrix-set minimum x and maximum y locate tile zero, zero. Columns and rows are zero-based and bounded by the width and height of the matrix at the selected zoom. Tile pixel dimensions and positive pixel sizes define the span of each tile. These metadata values belong to a table and zoom relationship; they should be read together before interpreting an extracted image. The standard permits sparse matrices, so the rectangular matrix extent is not proof that every possible tile is present.

In practice, record the matching gpkg_tile_matrix_set row and gpkg_tile_matrix row, including the spatial reference, dimensions and pixel sizes. Compare those with the selected tile table and zoom. Avoid importing an assumed tile size, global extent or square matrix from a previous project. If the receiving tool asks for a row convention, determine what its input expects and document any deliberate conversion separately. This is a metadata interpretation task before it is an image editing task. Rotating or flipping the tile pixels cannot resolve an incorrectly identified matrix origin.

NiVO VTOL V5 product image showing the fixed wing and vertical-lift rotors
NiVO VTOL V5 product image showing the fixed wing and vertical-lift rotors.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.

Calculate a constructed envelope without opening a package

Consider a teaching matrix with four columns and three rows. Each tile has two hundred fifty-six pixels along each side, with a pixel size of one half map unit in both directions. Its upper-left corner is x one thousand and y five thousand. Each tile therefore spans one hundred twenty-eight units. In column one, row zero has an upper edge at five thousand, while row two has an upper edge at four thousand seven hundred forty-four. These invented values demonstrate the indexing convention; they are not coordinates, dimensions or coverage measured from a NiVO delivery.

The Python function below checks a bounded set of input types and ranges, then returns minimum x, minimum y, maximum x and maximum y for one tile. It accepts already identified metadata rather than querying a database. Increasing the column adds one tile span to x; increasing the row subtracts one tile span from the upper y. This is a direct envelope calculation, not a coordinate transformation, tile decoder or complete metadata validator. The caller must still establish the matching source table, zoom, reference system and consistency of the full matrix extent.

import math

def tile_envelope(meta, column, row):
    integers = ("matrixWidth", "matrixHeight", "tileWidth", "tileHeight")
    for name in integers:
        if type(meta[name]) is not int or meta[name] <= 0:
            raise ValueError("positive integer metadata required: " + name)
    for name in ("minX", "maxY", "pixelX", "pixelY"):
        value = meta[name]
        if type(value) not in (int, float) or not math.isfinite(value):
            raise ValueError("finite numeric metadata required: " + name)
    if meta["pixelX"] <= 0 or meta["pixelY"] <= 0:
        raise ValueError("positive pixel sizes required")
    if type(column) is not int or not 0 <= column < meta["matrixWidth"]:
        raise ValueError("column outside selected matrix")
    if type(row) is not int or not 0 <= row < meta["matrixHeight"]:
        raise ValueError("row outside selected matrix")
    span_x = meta["tileWidth"] * meta["pixelX"]
    span_y = meta["tileHeight"] * meta["pixelY"]
    left = meta["minX"] + column * span_x
    top = meta["maxY"] - row * span_y
    result = (left, top - span_y, left + span_x, top)
    if not all(math.isfinite(value) for value in result):
        raise ValueError("nonfinite calculated envelope")
    return result

# Constructed map units; no database or real survey is opened.
meta = {"matrixWidth": 4, "matrixHeight": 3,
        "tileWidth": 256, "tileHeight": 256,
        "pixelX": 0.5, "pixelY": 0.5, "minX": 1000, "maxY": 5000}
print(tile_envelope(meta, 1, 0))
print(tile_envelope(meta, 1, 2))

Distinguish a matrix envelope from the tiles actually delivered

An envelope calculation tells you where an indexed tile would belong under the supplied metadata. It does not prove that a tile record exists there, that its image decodes correctly or that the pixels contain useful observations. Retain those as separate checks. When comparing a sparse package with an expected delivery area, inventory the actual tile keys instead of multiplying the matrix dimensions and describing the product as complete coverage. A deliberate empty area, a transparent image and an absent tile record also need different explanations in the receiving workflow.

Select a few actual tile records for review only after their package, table and zoom identities are established. Compare the predicted placement with independent delivery context and record the application used to decode the image. Check edges and neighboring tile relationships without using visual continuity as the sole acceptance criterion. A smooth seam can hide a placement assumption, while a visible boundary can reflect legitimate image content. Keep the selected sample identifiable so the producer can investigate it. Do not overwrite tile rows or repack the database merely to make one preview appear aligned.

Account for the receiving raster view and its extent

The GDAL GeoPackage raster documentation distinguishes the extent exposed by the driver from the full tile-matrix extent. It describes use of gpkg_contents bounds when available, fallback to matrix-set bounds and an option to use actual tile extent. That means a receiving raster view and the matrix rectangle need not have identical boundaries. Record the software version and opening options when comparing a reported extent with a tile envelope. This tutorial does not execute GDAL, inspect its installed version or assert what a particular receiving application selected.

If two tools report different map bounds, first ask whether they opened the same table and zoom with the same extent policy. Then compare the relevant metadata and any clipping behavior. Avoid converting a difference in presentation into an unsupported claim of lost observations. Likewise, an extent that matches the expected rectangle does not establish spatial accuracy. The project still needs its own reference, content and acceptance checks. For NiVO handoffs, keeping these questions separate makes an export discussion easier to reproduce and reduces the chance that a display option is mistaken for a source-data correction.

Deliver a reproducible placement explanation

Include the package identity, tile table, zoom, row and column, matrix dimensions, tile pixel dimensions, pixel sizes, reference system and matrix-set origin with the calculated envelope. State the coordinate order used in the report. Retain the original metadata values alongside the calculation so another analyst can reproduce the placement. Where a receiving system requires a different indexing convention, describe the explicit conversion and its inputs rather than silently relabeling the original tile identifier. Keep any generated mosaic separately identified from the accepted source package.

The resulting explanation is intentionally narrow but useful: this tile key maps to this envelope under these matrix values. It does not claim a complete GeoPackage conformance result, decoded-image quality, full survey coverage or analytical suitability. If a metadata inconsistency remains, preserve it and obtain a corrected release through the producing workflow. Repeat the placement review against that new revision. The central habit is to let the actual matrix define the row interpretation before changing anything. That provides a defensible basis for a NiVO raster discussion instead of relying on assumptions imported from an unrelated map grid.

Technical references

  1. Approved OGC GeoPackage 1.4.0: tile matrix and tile indexing ↗
  2. GDAL GeoPackage raster: opening extents and options ↗
← All articles

Related articles

All articles ↗
LET’S TAKE FLIGHT

Your next mission
starts with a conversation.

Talk to our team