Shape Files Indexing

To provide faster access, ESRI Shapefiles can be indexed using the shptree utility. This is especially to consider with large files.

What does it do?

shptree will create index files (extension .qix) read by MapServer containing Spatial Index information to allow faster access. The method used is called quadtrees. The basic principle of quadtrees is to cover a planar region of interest by a square, then recursively partition squares into smaller squares. Using shptree, the default tree depth is calculated so, that each tree node (quadtree cell) contains 8 shapes. Example of a quadtree structure:

Usage

SYNTAX
 

shptree <shpfile> [<depth>]

Where:

  • <shpfile> is the name of the .shp file to index.

  • <depth> (optional) is the maximum depth of the index
    to create, default is 0 meaning that shptree will calculate automatically the default depth (calculated so, that a quadtree cell contains 8 shapes). Do not use the default depth with point files, here a depth between 6 and 10 works fine.

Examples:

shptree lakes.shp
shptree poles.shp 7