I've created a Spatialite layer with all of the waterbodies and watercourses in Saskatchewan for use in QField. Rendering is quite slow on both my older laptop and my field device - a G5 cell phone. When I look at the layer properties I see that the "create spatial index" button is disabled.

I know that Spatialite supports spatial indexes, but it's not clear from what I've read whether the newer virtual spatial index is created automatically or if I need to enable it somehow. If it is truly virtual then I assume it is created on the fly, which would be a bad thing in the case of QField. It's also not clear whether QField will use spatial indexes but that's a question for a different forum.

  • You can open your Spatialite db with Spatialite-gui program which makes it easy to check or create the spatial index.
    – user30184
    Jun 28, 2017 at 16:14
  • 1
    If you prefer to stay in QGIS interface, try DB Manager. (1) On DB Manager, right click on Spatialite, and New Connection then select your .sqlite. (2) select your table (whose name is same as your layer) and from menu Table | Edit Table. (3) On Table properties window, go to Indexes tab and click on [Add spatial index] button.
    – Kazuhito
    Jun 28, 2017 at 16:38
  • @Kazuhito I tried that but I got a "no such module: VirtualSpatialIndex" error. Now when I open it in spatialite-gui recommended by user30184 I can see a spatialindex table but I get the same error if I click on it.
    – marcp
    Jun 28, 2017 at 18:50
  • Thanks @marcp Re-reading your post, I found myself having not quite understood what was virtual spatial index. Could you expound this a bit, and whether it requires any different filetype? (I was just assuming QField was accessing usual sqlite file). And adding info about your workflow to create your Spatialite layer would also be helpful.
    – Kazuhito
    Jun 28, 2017 at 23:55
  • 1
    @Kazuhito the Virtual spatial index is just the name for the spatial index, which is not virtual at all. See my answer.
    – marcp
    Jun 30, 2017 at 22:47

1 Answer 1


After lots of messing around I've determined that the spatial indexes are indeed there and can be created when the table is being created, quite simply. In my case I used Save as to save a selection as a new Spatialite table and 'create spatial index' is an option.

In a current version of spatialite-gui you can see the Spatial Index within the structure of the Spatialite file - not the table itself, although there are table specific indexes within it.

I specified the current version of the gui utility because there are a number of downloads available of older versions, which is where I went wrong the first time. Choose the appropriate link here (https://www.gaia-gis.it/gaia-sins/index.html) to get the current version.

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.