[Mapserver-users] why does my raster layer turn my shapefile layer gray?

Ed McNierney ed at topozone.com
Mon Mar 10 20:54:44 EST 2003


Chris -

Today must be "I ran out of colors" Day <g>.

This is the same issue Aaron Hunt posted under "TRANSPARENCY problem",
and was discussed under "COLOR_MATCH_THRESHOLD" a few days ago.

You're running out of colors in your 8-bit output image.  MapServer
renders one layer at a time, starting from the beginning of your MAP
file, and allocates new colors as needed by each layer.  After you've
drawn enough layers to use 256 distinct colors, all subsequent layers
are stuck with the 256 colors already defined, and MapServer chooses the
closest fit.

If you display just the "baylands" layer, you use up two colors - two
shades of blue.  If you display just the "bayraster" layer, you get (I
presume) 256 shades of gray.

If you display the "bayraster" layer AND the "baylands" layer, the
"bayraster" layer allocates 256 shades of gray, and there aren't any
more palette colors available to create shades of blue - so the
"baylands" layer is drawn using the shades of gray closest to those two
shades of blue.  And that's not very close.

Solution path #1 - Use the OUTPUTFORMAT block in 3.7 to create a 24-bit
output image.  You will then get much larger map images, but you will no
longer be constrained to the 256 colors in an 8-bit image.

Solution path #2 - If you're using GDAL to read raster layers, see the
mailing list for the COLOR_MATCH_THRESHOLD statement, which will cause
MapServer to select a "close" match instead of an exact match when
allocating colors for the raster layer.  This will result in an
on-the-fly reduction in the number of colors used by your raster layer;
instead of using up a different palette entry for every unique shade of
gray, MapServer will consider a near match to be "close enough" and use
that existing shade of gray.  This will mean that there are some palette
colors still available when you get around to drawing the "baylands"
layer.

	- Ed

Ed McNierney
President and Chief Mapmaker
TopoZone.com / Maps a la carte, Inc.
73 Princeton Street, Suite 305
North Chelmsford, MA  01863
Phone: (978) 251-4242  Fax: (978) 251-1396
ed at topozone.com


-----Original Message-----
From: Chris Black [mailto:cblack at CalAcademy.Org] 
Sent: Monday, March 10, 2003 8:44 PM
To: mapserver-users at lists.gis.umn.edu
Subject: [Mapserver-users] why does my raster layer turn my shapefile
layer gray?

Hello all,

I have a map with two layers: one is an ArcView grid file that is a 
relief map of the SF Bay Area in various shades of gray.  The other is a

shapefile that show the bay waters in two classes, shallow and deep.  If

I display just the shapefile layer ("Baylands" in the mapfile below), 
these two classes are two different shades of blue.  If I display the 
raster layer ("bayraster") as well, the classes are changed to shades of

gray.  Why does it happen, and how can I get my colors back?

Much thanks for any help.

-- Chris

Mapserver version string:  "MapServer version 3.7 (development) 
OUTPUT=PNG OUTPUT=JPEG OUTPUT=WBMP OUTPUT=PDF OUTPUT=SWF SUPPORTS=PROJ 
SUPPORTS=TTF SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT SUPPORTS=WFS_SERVER

SUPPORTS=GD2_RGB INPUT=EPPL7 INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE"

I view the map with the url 
"http://localhost/Scripts/mapserv.exe?map=C:/inetpub/wwwroot/mapserverap
ps/IZG/testraster.map&mode=map"

testraster.map:
--------------- cut here ----------------------
# Note: Comments in a map file are preceeded by the pound (#) sign.
# When MapServer encounters the pound sign, it will ignore the
# rest of the line.  Unfortunately, you can't comment a whole block
# of code or text in MapServer.  So, you're stuck with adding pound
# signs for every line you wish to comment out.


NAME CALCTYEX1
EXTENT 467416 4085763 623532 4288980
SIZE 350 300
UNITS METERS
SHAPEPATH "C:\inetpub\wwwroot\MapServerApps\IZG\data\"
SYMBOLSET "C:\inetpub\wwwroot\MapServerApps\symbols\symbols.sym"



LAYER
    data "c:\inetpub\wwwroot\sfbay\data\EcoAtlas\grid\sfbayshr"
    NAME "bayraster"
    STATUS DEFAULT
    TYPE RASTER
    CLASS
        NAME "Relief Map"
    END # CLASS
END # LAYER
LAYER
    NAME "Baylands"
    DATA "vector\mbypsfby"
    STATUS DEFAULT
    TYPE POLYGON
    CLASS
        NAME "Deep Bay"
        EXPRESSION ('[ENTITYID]' = 'A00000000000')
        COLOR 51 51 255
    END # CLASS
    CLASS
        NAME "Shallow Bay"
        EXPRESSION ('[ENTITYID]' = 'A10000000000' OR '[ENTITYID]' = 
'A10000000090' OR '[ENTITYID]' = 'B4ST00000000')
        COLOR 102 102 204
    END # CLASS
END # LAYER
END # FILE

--------------- cut here ----------------------------
I don't understand grid files very well, so here's the listing of the 
grid directory and its children in case something is wrong there (though

I don't think so, since the grid itself displays ok):
-------- cut here -----------------
C:/Inetpub/wwwroot/sfbay/data/EcoAtlas/grid:
info
sfbayshr
sfbayshr.met
sfbayshrw
sfbr-sr-dbdesc.txt

C:/Inetpub/wwwroot/sfbay/data/EcoAtlas/grid/info:
arc.dir
arc0000.dat
arc0000.nit
arc0001.dat
arc0001.nit
arc0002.dat
arc0002.nit
arc0002r.001

C:/Inetpub/wwwroot/sfbay/data/EcoAtlas/grid/sfbayshr:
dblbnd.adf
hdr.adf
log
prj.adf
sta.adf
vat.adf
w001001.adf
w001001x.adf
---------- cut here ----------------

_______________________________________________
Mapserver-users mailing list
Mapserver-users at lists.gis.umn.edu
http://lists.gis.umn.edu/mailman/listinfo/mapserver-users




More information about the mapserver-users mailing list