[gdal-dev] caching & spatial indexing of shapefiles?

Mateusz Loskot mateusz at loskot.net
Thu Sep 25 11:15:19 EDT 2008

Tom Kazimiers wrote:
> Hi there,
> the documentation gave me no real answer to the question if there is
> something like a caching mechanism for feature request. If I request a
> feature, is this read from disk every time or somehow cached?


AFAIK, there is no caching mechanism.
I've it on my TODO list to develop a thin wrapper on Shapelib or OGR that
will provide caching support, to minimize disk I/O operations.

> Another thing I could not find out is how I can activate spatial
> indexing for shape files - the documentation says I should execute the
> following SQL command: CREATE SPATIAL INDEX ON tablename [DEPTH N]
> But what is tablename and how do I know if the spatial index is created?

Spatial index is automatically activated if OGR Shapefile driver finds
.qix file for your Shapefile.

Let's say you have Shapefile called roads.shp|.shx|.dbf
Tablename is "roards" - a filename without extension.

Here you can find some real example:


Best regards,
Mateusz Loskot

More information about the gdal-dev mailing list