grouping raster tiles for mapserv WMS

Ed McNierney ed at TOPOZONE.COM
Fri Feb 18 14:50:40 EST 2005


Jeff -

You're close.  You want to group each set of same-resolution files
together with a single gdaltindex shapefile, and create one layer for
each index file.  That layer should also belong to a GROUP, and all
layers will have the same GROUP name.

I'm not exactly sure, but it sounds like you have ONE TIFF image for any
given resolution, rather than a set of tiles.  Is that correct?  If so,
you don't need a TILEINDEX (you have no tiles).  Just reference each
TIFF image with a DATA statement rather than a TILEINDEX statement.

Each layer will have a MINSCALE and MAXSCALE such that at any given
scale only one of the layers in the group is active.  An abbreviated
example would look like:

LAYER
        NAME            Image1m
        GROUP           Image
        DATA            Image1m.tif
        MINSCALE        0
        MAXSCALE        10000
END
LAYER
        NAME            Image4m
        GROUP           Image
        DATA            Image4m.tif
        MINSCALE        10000
        MAXSCALE        40000
END
LAYER
        NAME            Image16m
        GROUP           Image
        DATA            Image16m.tif
        MINSCALE        40000
        MAXSCALE        160000
END

Or something like that.  The map image requests would specify the group
name "Image" rather than individual layers.

The MINSCALE and MAXSCALE units can be confusing.  They are the
denominators of a scale ratio (like 1:10,000).  They are interpreted in
the context of the RESOLUTION and UNITS statements at the top level of
the map file.  The default for RESOLUTION is 72, meaning that your
output image is presumed to be printed at 72 dots per inch unless you
say otherwise.  A physical output resolution is required in order to
calculate scale as a ratio (rather than saying "1 meter per pixel", for
example).

If your RESOLUTION is 72 and your UNITS are METERS (a sensible choice)
then 1:10,000 scale means that 1 meter on the output map equals 10,000
meters of the image.  1 meter on the output map is 39.37 inches, and at
72 pixels per inch, that's 72 * 39.37 = 2834.64 pixels.  So 10,000
meters of map data would span 2,834.64 pixels, and the image resolution
would be 10,000 / 2,834.64 = about 3.53 meters per pixel.

If you are unfortunately in a position where you are somehow compelled
to generate an output image in some completely useless and meaningless
output units such as "degrees", the situation is similar.  You need to
specify UNITS DD, and then you're trying to measure "degrees per inch".
So a scale of 1:10,000 means one "degree" on the output image equals
10,000 "degrees" on the map.  Since "degree" is an angular measure
rather than a linear one, this is a meaningless relationship, and a good
reason to avoid making maps in the geographic "projection".

At the Equator, one degree is very close to 60 nautical miles, or 60 *
1853 = 111,180 meters.  So we can translate "one degree" to "111,180
meters" and read that 1:10,000 means 111,180 meters on the output image
equals 10,000 degrees on the map.  At 72 DPI, that means 315,155,275.2
pixels per 10,000 degrees or 0.00003173 degrees per pixel, or 0.114228
seconds per pixel.

Of course, if you're not making a large-scale map centered on the
Equator, those calculations will be wrong.

        - Ed

Ed McNierney
TopoZone.com

-----Original Message-----
From: UMN MapServer Users List [mailto:MAPSERVER-USERS at LISTS.UMN.EDU] On
Behalf Of Jeff de La Beaujardiere
Sent: Friday, February 18, 2005 1:32 PM
To: MAPSERVER-USERS at LISTS.UMN.EDU
Subject: [UMN_MAPSERVER-USERS] grouping raster tiles for mapserv WMS

Suppose I have a large TIFF image cut into tiles forming a
multi-resolution pyramid (each tile is a separate TIFF, not
a tiled TIFF).  I would like to have mapserv access the
lowest-resolution tile that covers the area of interest at
the user-requested size.

I created a single .shp file using gdaltindex referencing
all of my tiles, in order from lowest to highest resolution,
but mapserv does not seem to be taking advantage of that
TILEINDEX (that is, mapserv quickly renders high-res local images
but is slow to create a global overview).  Have I misunderstood
how a .shp file is supposed to be created and used?

I would like to have a separate TILEINDEX at each resolution,
with appropriate MINSSCALE and MAXSCALE, but I don't see how
to group those in a single WMS LAYER since CLASS can contain
MINSCALE and MAXSCALE but cannot contain TILEINDEX (i.e., it
seems only 1 TILEINDEX is permitted for each LAYER).

Confused,
Jeff DLB
mapserv newbie

P.S. Also, the expected units of MIN/MAXSCALE do not seem to be
documented - is it coordinate units per pixel or what? My
input data are in lon-lat.



More information about the mapserver-users mailing list