can not get tileindex working

Stephen Woodbridge woodbri at SWOODBRIDGE.COM
Mon Sep 5 08:38:31 EDT 2005


Hi Xin,

It is a little more complicated than you have tried, I will try to 
explain it.

First, don't worry about shp2tile, most people do not need it and you 
would need to get the basic mapserver working and the tileindexes 
working first, before you can assess if you need it.

For performance you need to make sure all *.shp files have a *.qix file
    find /path/to/data -name "*.shp" -exec shptree {} \;
These are spatial indexes and not having these on all files is the 
primary reason for poor performance. Do this first and see how you 
performance is.

Tileindexes are a way of group lots of similar files together into a 
single layer. This is most useful if you have thousands of shapefiles 
that represent the roads (or whatever) of a country and each file is in 
a separate directory say organized by province or region. Then you can 
create one layer and use the tileindex to collect all the files together 
and control them in a single layer.

Tileindexes have constraints on them as follows:
1) they should generally be of the same shape type (as you mentioned)
2) all the files referenced in an index MUST have the same attribute 
structure. This means that if the first file added to the index has 4 
attribute columns say, for example, (int,string,string,double) with 
names (GID,NAME,TYPE,AREA), then ALL files added to the index must have 
the SAME columns in the SAME order.

Tileindexes are also used in some cases where you have done all the 
above, but you have a really HUGE shapefile. HUGE being lots of objects, 
like 100s of thousands, that a spatially diverse. Then you can use 
shp2tile to chop the large file into lots of smaller files where the 
objects are grouped spatially. Then you use a tileindex to bring them 
all together again into a single layer. If you do this don't forget to 
create *.qix files for all the new shapefiles. I also recommend that you 
put all the tiled files into a directory, like roads.shp into roads/

Hope this helps,
   -Steve W.
    http://imaptools.com

Xin wrote:
> Hi list,
> 
> I've searched the archives endlessly, and though there's been alot of 
> posts on this I still can't seem to get the hang of it.
> 
> I'm trying to index my shapefiles, as I've been told this will give it a 
> performance boost.  All my data are all in one directory, and they're 
> roughly half a gig in size.  It is operating rather slowly at the 
> moment, taking a few seconds to display all the layers.
> 
> This is how I initially tried to use tile index on my data:
>    ogrtindex *.shp tileindex.shp         # to index all my shapefiles
> in the map file, add below to every layer:
>     TILEINDEX "tileindex.shp,0"            # and remove DATA tag
> 
> This doesn't work!
> 
> I've since read you have to group different types together into one 
> index file.  i.e. all the POINTS in one, LINES in another etc.  So you 
> would have say 4 tile index files, each corresponding to each type.  
> Then would I use these filenames, i.e. TILEINDEX "pointindex.shp".  Is 
> this the right way, anyway to automated?  And what are shptree used for?
> 
> I tried to use imaptools.com <http://imaptools.com>'s shp2tile, but the 
> library it depends on(shapelib) wouldn't compile.
> 
> One last question.  What's qix and should I use it?
> 
> Thank you inadvance for your help.
> 
> Regards,
> Xin
> 



More information about the mapserver-users mailing list