16

Working in QGIS 2.18.14 standalone on Windows, is there a way to create a Spatial Index for GeoPackage (gpkg) layers?

Taras
  • 32,823
  • 4
  • 66
  • 137
Kazuhito
  • 30,746
  • 5
  • 69
  • 149

3 Answers3

20

It's possible in QGIS 3. You can click "Create Spatial index" from the Layer Properties Dialog:

enter image description here

Taras
  • 32,823
  • 4
  • 66
  • 137
ndawson
  • 27,620
  • 3
  • 61
  • 85
9

I don't believe that it is possible through the QGIS UI at the moment. Read the GDAL GeoPackage vector manual http://www.gdal.org/drv_geopackage.html and use ogrinfo.

ogrinfo -SQL "SELECT CreateSpatialIndex('table_name', 'geom_column_name')" geopackage.gpkg
user30184
  • 65,331
  • 4
  • 65
  • 118
1

There's also the processing tool: Create spatial index:

Creates an index to speed up access to the features in a layer based on their spatial location. Support for spatial index creation is dependent on the layer's data provider.

BERA
  • 72,339
  • 13
  • 72
  • 161
  • 1
    Yes, thanks. I guess this processing tool has been around since QGIS 2.16, which worked only for shapefiles at the time of the question. – Kazuhito Sep 08 '21 at 13:12