SQLite Forum

suggest:for geopoly,advice to add primary key like rtree
Login
See the documentation <https://sqlite.org/geopoly.html>

A Geopoly virtual table has two pre-defined columns that have names you cannot change:  `rowid` and `_shape`.  

The rowid (integer primary key) of the row is called `rowid`.

The description of the polygon is called `_shape`.

The parameters you specify to the name geopoly when you are creating a geopoly table are additional data columns in addition to the `rowid` and the `_shape`.  (Like column names prefaced with a `+` in r-tree tables).

So, using your `pathway` table above and assuming that `rect` contains a geojson area description, then you would declare and fill the geopoly table `path_index` as follows:

```
create virtual table path_index using geopoly();
insert into path_index(rowid, _shape) select id, rect from pathway;
```

Of course, you should fix your definition of `id` in `pathway` so that it is properly spelled `integer primary key`.  A `bigint primary key` is not an `integer primary key` (rowid).

See <https://sqlite.org/rowidtable.html>