GeoPackage RTree Queries: Audit Candidates in a Drone Inventory
Inspect a GeoPackage spatial index and distinguish bounding-box candidates from exact geometry matches before accepting an area query on a drone-derived inventory.

Define what an area query is meant to return
A drone-derived asset inventory can return a plausible selection by map area while leaving an important question unresolved: did the query test actual geometries or only their bounding boxes? Before accepting a NiVO survey-delivery query, identify the layer, file revision, coordinate reference and intended spatial relationship. Intersecting an area, lying completely inside it and touching its boundary are different tasks. This tutorial inspects a GeoPackage RTree workflow. It does not claim that an actual project database was queried or that a particular NiVO product creates or maintains a spatial index directly.
Preserve an identified, consistently released copy of the package before the review. Record the receiving application, relevant library versions and the stable feature identities needed for comparison. A map selection may also reflect attribute filters, display scale or layer visibility, so keep those presentation choices separate from the spatial predicate. Define the expected result using project evidence rather than assuming every object visible in a screen rectangle belongs in the delivered selection. The aim is a reproducible explanation of the query, not merely a faster display or a count that happens to match an informal expectation.
Identify the index relationship and its scope
GeoPackage 1.4.0 defines the gpkg_rtree_index extension for indexed geometry columns, with a virtual table related to a feature table and geometry column. It also specifies maintenance triggers. Identify those relationships through the actual package rather than guessing an index name from the layer label shown in a GIS. A missing optional index does not by itself prove that the feature geometries are invalid. Conversely, the presence of a correctly named table is not evidence that its entries remain consistent with every accepted feature or that all required maintenance behavior is supported by the writing application.
The specification excludes null and empty geometries from initial index population. Therefore comparing the number of index entries with every feature-table row is not automatically a valid completeness test. Establish which records have relevant geometry and how the actual package represents them. Keep any unexplained difference visible without deleting rows to force agreement. An index helps locate candidate features; its existence does not establish the meaning of the mapped objects, the correctness of their reference or whether a particular query implements the spatial relationship required by the survey-delivery task.

Product context only; this photograph does not depict the constructed examples in this article.
Inspect the declared indexed columns read-only
Open the accepted copy through a suitable read-only inspection workflow and first confirm which metadata tables exist. If gpkg_extensions is present, the query below lists declarations for indexed columns. A package without that table needs appropriate interpretation instead of an assumption that every metadata query must succeed. Retain the actual output and file identity when performing a real review. No query was executed on a project package for this article, and no fabricated table listing is supplied. The statement is a narrow metadata inspection, not a validation report or an instruction to create an index.
Compare the declared table and geometry column with the actual layer schema and the associated RTree table and triggers. Use maintained GeoPackage-aware tooling for a version-sensitive conformance assessment where required. Merely counting trigger names is not a complete check of their definitions or behavior. If a query tool lacks the necessary spatial functions or extension support, preserve that limitation and select an appropriate receiving environment. Do not repair an accepted package by manually adding guessed rows or dropping index tables during the investigation; keep any justified corrective revision separate from the preserved original.
-- Read-only metadata query, after confirming gpkg_extensions exists.
SELECT table_name, column_name, scope
FROM gpkg_extensions
WHERE extension_name = 'gpkg_rtree_index';Query an envelope as a candidate stage
The following constructed example assumes a feature table called asset_findings with geometry column geom and its correctly identified index. The window spans X from one hundred to two hundred and Y from three hundred to four hundred in unspecified teaching coordinates. These numbers are not a surveyed site or a recommended project reference. The inequalities select overlapping index envelopes, including boundary contact. They do not inspect polygon interiors or line segments. Preserve the query window, reference definition and chosen relationship in an actual review, and use the verified package names rather than treating the teaching schema as an existing delivery.
SQLite documents that ordinary RTree coordinate bounds use single-precision storage with outward rounding. This can introduce extra overlap candidates near a boundary; strict contained-within queries need separate care. Do not invent a universal survey tolerance to hide that distinction. After candidate retrieval, use a suitable exact geometry operation for the required relationship and the actual reference context. A polygon with a hole, an elongated line or an object whose envelope covers empty space can illustrate why a candidate is not automatically a final match. The exact result and any numerical assumptions need their own evidence.
-- Constructed schema/window: envelope candidates, not exact geometry matches.
SELECT id
FROM rtree_asset_findings_geom
WHERE minx <= 200 AND maxx >= 100
AND miny <= 400 AND maxy >= 300;Compare candidate and geometry results without hiding discrepancies
For an actual acceptance check, retain candidate identities and the final geometry-test identities separately. Compare selected boundary cases and known features with a supported independent geometry evaluation that does not rely solely on the same candidate list. This matters if the question concerns index consistency: an omitted candidate cannot be recovered by testing only the candidates that were returned. Record the actual method and scope of the comparison. A few successful samples can help locate an interpretation issue but cannot establish that every index entry and every feature in a large delivery passed validation.
If results differ, investigate the predicate, window reference, null or empty geometries, application filters and index-to-feature relationship before attributing the difference to survey quality. Preserve feature identities and diagnostics so the finding can be reproduced. A supported reindexing or export operation may be appropriate after the cause is established, but it should produce a traceable candidate revision with its own checks. The tutorial does not perform such a repair. A query becoming faster or producing a visually convincing selection is not sufficient evidence that the intended feature set was recovered or that the underlying geometries are correct.
Deliver the query interpretation with the inventory
A useful handoff names the file revision, layer, indexed column, reference, query window and exact spatial relationship tested. Include the actual candidate and final-result findings, tool versions, relevant warnings and unresolved limitations. Another analyst should be able to select a reported feature and explain why it entered or left the final result. Keep performance observations separate and report them only when measured under identified conditions. The presence of an RTree extension alone supplies neither a speed benchmark nor evidence that a map selection represents the complete analytical result required by the project.
For NiVO inventory discussions, this turns an ambiguous area-selection complaint into a precise question about the index, geometry and predicate. It also protects the distinction between a delivery representation and the interpretation of the survey features it contains. Preserve the accepted original and any unresolved reference or consistency issue with the review. The result is a reproducible preparation step for actual spatial analysis, with no implied claim that a candidate count proves coverage, that a bounding box is an observed object or that an unexecuted query validated a real customer inventory.



