What I’ve done in the past is to extract the bounds contained in the root node of the rtree (if it exists of course). This is less precise than querying the data since the rtree only stores the extent using single precision floating point, but it is obviously much much faster since it’s an O(1) operation.
The rtree nodes are stored in one of the shadow tables. It gets created as
CREATE TABLE <rtree_table_name>_node(nodeno INTEGER PRIMARY KEY, data BLOB)
The root node is guaranteed to have nodeno 1. By design the extent stored in each node in an rtree is the union of the extents of all its children. As a consequence the root node is guaranteed to have an extent the contains all the indexed entries.
The layout of the blob is
int16 rtree_depth;
int16 nb_entries;
<nb_entries times>
int64 child_nodeno
float32 min_x;
float32 max_x;
float32 min_y;
float32 max_y;
You’ll need to query the blob using SQL and then calculate the union of the extent for each entry record. There’s no way to query these values directly AFAIK. The comment section at the top of
<sqlite>/ext/rtree/rtree.c describes this in more detail.
Best regards,