Optimize data for speed

Gregor Mosheh gregor at HOSTGIS.COM
Wed Dec 13 14:41:14 EST 2006


I'd like to enhance on what Brock said, in case Fabian's not familiar with
some of the concepts or how-to specifics.

First, you'll of course want to copy those compressed shapefiles off the
DVD and "gunzip" them to get your shapefiles. Example:
   cp * /home/mymap/data
   cd /home/mymap/data
   gunzip *.gz


The shptree utility will create a spatial index (a .qix file) for each
shapefile, which makes it faster to use that shapefile. Usage:
  shptree example.shp
   OR
  cd /home/mymap/data
  for x in *.shp ; do shptree $x ; done


If you want to use all of those shapefiles as one giant layer, then you'll
want to use the "ogrtindex" to create a "tile index" A tile index is a
shapefile that contains not data, but references to other data sources
(e.g. other shapefiles). You then create a tileindex layer in Mapserver,
and the driver knows to examine the meta-shapefile to decide which
shapefile(s) should actually be used. Usage:
   ogrtindex all_data.shp data/*.shp
Keep in mind that the paths in the tindex must be exactly the same as
they'd be if you were calling the shapefile itself. I recommend that you
cd into the directory you specify as your SHAPEPATH and then run the
command from there, to ensure that the tileindex has the exact same paths
to the individual shapefiles.


To use a tileindex layer in Mapserver, try this:
LAYER
  NAME "nationwide"
  STATUS on
  TYPE polygon
  TILEINDEX "all_data.shp"
  TILEITEM "location" # this is the default, probably what you want
  CLASS
    (insert class/color info here)
  END
END


I hope that helps!



More information about the mapserver-users mailing list