[Mapserver-users] why does my raster layer turn my shapefile layer gray?
Dylan Keon
keon at nacse.org
Tue Mar 11 11:03:36 PST 2003
Chris,
Another option is to export your grayscale shaded relief grid to a
georeferenced tiff image, then reduce the color depth of that image
using something like Irfanview or Imagemagick. Try Irfanview since
you're on Windows. Reduce to 64 or 32 colors and see how it looks...you
probably won't notice any difference. This will allow you to use 8-bit
output, and will also result in smaller file size. After that you could
also use gdaladdo (part of GDAL) to add overviews to the tiff image to
improve rendering times.
If you do stick with 24-bit output you could set up your PHP script so
that 24-bit output is used only when the "bayraster" layer is on (or in
scale range), and 8-bit output when the layer is off (or out of scale
range). Of course, this won't make any difference if you leave that
layer on all the time.
--Dylan
--
************************************************
Dylan Keon
GIS/Database Research Specialist
Northwest Alliance for Computational
Science and Engineering (NACSE)
Oregon State University
Corvallis, OR 97331
keon at nacse.org (541) 737-6608
************************************************
Chris Black wrote:
> Thanks, Ed and Dylan; my problem is solved. I added the following to my
> map file:
>
> OUTPUTFORMAT
> NAME png24bit
> DRIVER "GD/PNG"
> MIMETYPE "image/png"
> IMAGEMODE RGB
> END
>
> And this to my php script:
>
> $map->selectOutputFormat('png24bit');
>
> Performance is slower, naturally, now that the images have more than
> doubled in size. I was *not* successful with adding 'PROCESSING
> "COLOR_MATCH_THRESHOLD=3"', as my 3.7 build isn't new enough (I pulled
> mapserver-3.7-win32-php4.3.0-gd2.zip
> <http://www2.dmsolutions.ca/mapserver/dl/mapserver-3.7-win32-php4.3.0-gd2.zip>
> from http://www2.dmsolutions.ca/mapserver/dl/ ; it's dated 10-Feb-2003.
> I don't want to get into the business of doing my own builds if I can
> help it (I'm on Windows; on *n*x I wouldn't mind so much), so I'll take
> the performance hit for now.
>
> Thanks again.
>
> -- Chris
>
> Ed McNierney wrote:
>
>>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