tile4ms(1) | tile4ms(1) |
tile4ms - create a tile index Shape data set for use with MapServer's TILEINDEX feature
tile4ms
[ metafile tilefile [-tile-path-only] | -h]
tile4ms creates a tile index Shape data set for use with MapServer's TILEINDEX feature. The program creates a Shape data set of rectangles from extents of all the Shape data sets listed in metafile (one Shape data set name per line) and the associated DBF with the filename for each shape tile in a column called LOCATION as required by mapserv.
Note: Similar functionality can be found in the GDAL commandline utilities ogrtindex ⟨http://www.gdal.org/ogrtindex.html⟩ (for vectors) and gdaltindex ⟨http://www.gdal.org/gdaltindex.html⟩ (for rasters).
tile4ms creates a Shape data set containing the MBR (minimum bounding rectangle) of all shapes in the files provided, which can then be used in the LAYER object's TILEINDEX parameter of the mapfile. The new filed created with this command is used by MapServer to only load the files associated with that extent (or tile).
Short Example
Create tileindex.shp for all tiles under the /path/to/data directory:
cd /path/to/data
find . -name "/*.shp" -print > metafile.txt
tile4ms metafile.txt tileindex
Long Example
This example uses TIGER Census data, where the data contains files divided up by county (in fact there are over 3200 counties, a very large dataset indeed). In this example we will show how to display all lakes for the state of Minnesota. (note that here we have already converted the TIGER data into Shape format, but you could keep the data in TIGER format and use the ogrtindex utility instead) The TIGER Census data for Minnesota is made up of 87 different counties, each containing its own lakes file ('wp.shp').
find -name *wp.shp -print > wp_list.txt
The newly created file might look like the following (after removing the full path):
001\wp.shp
003\wp.shp
005\wp.shp
007\wp.shp
009\wp.shp
011\wp.shp
013\wp.shp
015\wp.shp
017\wp.shp
019\wp.shp
...
tile4ms wp_list.txt index
Processed 87 of 87 files
Figure 1: Index file created by tile4ms utility
⟨http://mapserver.org/_images/tile4ms-view.png⟩
Figure 2: Attributes of index file created by tile4ms
utility
⟨http://mapserver.org/_images/tile4ms-attributes.png⟩
LAYER
NAME 'mn-lakes'
STATUS ON
TILEINDEX "index"
TILEITEM "location"
TYPE POLYGON
CLASS
NAME "mn-lakes"
STYLE
COLOR 0 0 255
END
END
END
When you view the layer in a MapServer application, you will notice that when you are zoomed into a small area of the state only those lakes layers are loaded, which speeds up the application.
shp2img(1), shptree(1), shptreetst(1), shptreevis(1), sortshp(1)
20 February 2019 |