16

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

3 Answers 3

20

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

enter image description here

1
  • Does this option also enable spatial index auto updates? Sep 15, 2020 at 7:35
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
1
  • I think you need "SELECT Create..." to make it work
    – JaakL
    Nov 6, 2019 at 20:18
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.

1
  • 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 8, 2021 at 13:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.