Gis Tricks

Spatialite virtualshape

Spatialite virtualshape

Recently we started to use spatialite as local storage. For a certain project we like to query spatialite in combination with a shapefile. For that luckily we have the VirtualShape extension.

dbmanager qgis

DBmanager in QGis

Usually I use dbmanager in QGis to connect to spatialite. So I first tried using the extension in this SQL editor.

 CREATE VIRTUAL TABLE test_shape USING VirtualShape(shape_towns, CP1252, 32632) 

Query succeeded, table was even created. But I only saw an empty table:
<a href="http://gistricks.com/wp-content/uploads/2014/09/2014-09-23_2131.png"><img class="size-medium wp-image-2429" src="http://gistricks.com/wp-content/uploads/2014/09/2014-09-23_2131-300x224.png" alt="Empty table" width="300" height="224" /></a> Empty table

What could be the problem? My first thought was that there was something wrong with the query or the encoding I used. So I fiddled around a bit with location of the shapefile, quotes and encoding. No result. More logical:  it could be QGis itself!

Next step was to install <a href="https://www.gaia-gis.it/spatialite-2.3.1/binaries.html" target="_blank">commandline </a>(why didn't I have this already?? ). I installed:
<ul>
	<li>libspatialite-win-x86-2.3.1.zip</li>
	<li>spatialite-tools-win-x86-2.3.1.zip</li>
</ul>
Both in the same directory.

I placed the shapefile also in this install directory and made exactly the same query as shown before. Then I did a simple  SELECT * FROM test_shape LIMIT 1 

and behold! It worked. Of course in QGis you can’t see anything, which does make sense. It is only meant for querying, not for viewing.

Leave a Reply

Your email address will not be published. Required fields are marked *

five × 5 =