[mapserver-users] question on Request For Comment #6

Even Rouault even.rouault at mines-paris.org
Tue Jul 2 12:51:15 PDT 2013


Le mardi 02 juillet 2013 20:18:58, Mark Volz a écrit :
> Steve,
> 
> Thanks for your help.  I was quite surprised at how quickly MapServer can
> draw the color ramps from a DEM.
> 
> 
> For others,
> 
> Here is a MapServer code snippet for using color ramps:
> 
>   CLASS
>     EXPRESSION ([pixel] >= 1621 AND [pixel] < 1670)
>     STYLE
>       COLORRANGE 0 0 0 255 255 0
>       DATARANGE 1621 1670
>       RANGEITEM "pixel"
>     END #end style
>   END #end class
>   CLASS
>     EXPRESSION ([pixel] >= 1670 AND [pixel] < 1713)
>     STYLE
>       COLORRANGE 255 255 0 0 0 255
>       DATARANGE 1670 1713
>       RANGEITEM "pixel"
>     END #end style
>   END #end class

An alternate way is to use the gdaldem utility from GDAL with the color-relief 
mode :  http://www.gdal.org/gdaldem.html

As a bonus, you can avoid generating a full new raster, by outputing to a VRT 
file (an XML file) that will only contain the LUT to map the elevations to 
colors.

gdaldem color-relief n43.dt0 dem.pct n43_pct.vrt -of vrt

with dem.pct :
3500   white
2500   235:220:175
50%   190 185 135
700    240 250 150
0      50  180  50
nv     0   0   0   0 

generates n43_pct.vrt  :

<VRTDataset rasterXSize="121" rasterYSize="121">
  <SRS>GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 
84",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433],AUTHORITY["EPSG","4326"]]</SRS>
  <GeoTransform> -80.00416666666666, 0.008333333333333333, 0, 
44.00416666666666, 0, -0.008333333333333333</GeoTransform>
  <VRTRasterBand dataType="Byte" band="1">
    <ColorInterp>Red</ColorInterp>
    <ComplexSource>
      <SourceFilename relativeToVRT="1">n43.dt0</SourceFilename>
      <SourceBand>1</SourceBand>
      <SourceProperties RasterXSize="121" RasterYSize="121" DataType="Int16" 
BlockXSize="1" BlockYSize="121"/>
      <SrcRect xOff="0" yOff="0" xSize="121" ySize="121"/>
      <DstRect xOff="0" yOff="0" xSize="121" ySize="121"/>
      <LUT>-32767:0,0:50,267.5:190,700:240,2500:235,3500:255</LUT>
    </ComplexSource>
  </VRTRasterBand>
  <VRTRasterBand dataType="Byte" band="2">
    <ColorInterp>Green</ColorInterp>
    <ComplexSource>
      <SourceFilename relativeToVRT="1">n43.dt0</SourceFilename>
      <SourceBand>1</SourceBand>
      <SourceProperties RasterXSize="121" RasterYSize="121" DataType="Int16" 
BlockXSize="1" BlockYSize="121"/>
      <SrcRect xOff="0" yOff="0" xSize="121" ySize="121"/>
      <DstRect xOff="0" yOff="0" xSize="121" ySize="121"/>
      <LUT>-32767:0,0:180,267.5:185,700:250,2500:220,3500:255</LUT>
    </ComplexSource>
  </VRTRasterBand>
  <VRTRasterBand dataType="Byte" band="3">
    <ColorInterp>Blue</ColorInterp>
    <ComplexSource>
      <SourceFilename relativeToVRT="1">n43.dt0</SourceFilename>
      <SourceBand>1</SourceBand>
      <SourceProperties RasterXSize="121" RasterYSize="121" DataType="Int16" 
BlockXSize="1" BlockYSize="121"/>
      <SrcRect xOff="0" yOff="0" xSize="121" ySize="121"/>
      <DstRect xOff="0" yOff="0" xSize="121" ySize="121"/>
      <LUT>-32767:0,0:50,267.5:135,700:150,2500:175,3500:255</LUT>
    </ComplexSource>
  </VRTRasterBand>
</VRTDataset>

that you can use as a raster name in your mapfile.


> 
> 
> Mark Volz, GISP
> GIS Specialist
> 
> > -----Original Message-----
> > From: Lime, Steve D (MNIT) [mailto:Steve.Lime at state.mn.us]
> > Sent: Monday, July 01, 2013 3:52 PM
> > To: Mark Volz; mapserver-users at lists.osgeo.org
> > Subject: RE: question on Request For Comment #6
> > 
> > The support (I believe) as described initially in the RFC does exist
> > within MapServer. It's not been formally documented/acknowledged because
> > I think there are some improvements that could be made to this initial
> > implementation. You might have some success with that in the interim. I
> > do hope a more complete (and documented) implementation could be
> > available as part of MapServer 7.0.
> > 
> > Steve
> > 
> > -----Original Message-----
> > From: mapserver-users-bounces at lists.osgeo.org [mailto:mapserver-users-
> > bounces at lists.osgeo.org] On Behalf Of Mark Volz
> > Sent: Monday, July 01, 2013 12:51 PM
> > To: mapserver-users at lists.osgeo.org
> > Subject: [mapserver-users] question on Request For Comment #6
> > 
> > Hello,
> > 
> > Has anything ever happened with RFC #6, or did this one stall out?  The
> > color range mapping could be useful in a couple of my applications.
> > 
> > Thanks
> > 
> > Mark Volz, GISP
> > GIS Specialist
> > 
> > 
> > _______________________________________________
> > mapserver-users mailing list
> > mapserver-users at lists.osgeo.org
> > http://lists.osgeo.org/mailman/listinfo/mapserver-users
> 
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users

-- 
Geospatial professional services
http://even.rouault.free.fr/services.html



More information about the MapServer-users mailing list