[mapserver-users] Mathematical Scaling of Floating Point Data in Mapserver Map File

Frank Warmerdam warmerdam at pobox.com
Wed May 12 13:05:54 PDT 2010


Peter Willis wrote:
> 
> Hello,
> 
> Is it possible to apply nonlinear scaling to classify
> floating point tiff rasters.
> 
> All examples that I have seen appear to assume a linear
> dataset.
> 
> If I wish to scale the data by the base 10 log
> of the data and then scale the Red, Green and Blue values
> of the classification, can I do it in the map file?
> 
> What are the available functions that may be used
> in the mapfile 'PROCESSING' and 'EXPRESSION' items?

Peter,

The short answer is that you cannot, in general, do non-linear
scaling.  Depending on the dynamic range of your data, you could
use classes to do something approximating non-linear scaling but you
need to be aware that in the background there is still a linear scaling
being done before the classification is applied to the "scaled buckets".
But you can request as many as 64K buckets which would still give you
pretty good control over something like four orders of magnitude.

You might use something like:

   PROCESSING "SCALE=0,100000"
   PROCESSING "SCALE_BUCKETS=64000"

   CLASS
     EXPRESSION ([pixel] < 2.5)
     COLOR 255 0 0
   END
   CLASS
     EXPRESSION ([pixel] < 10)
     COLOR 235 20 20
   END
   CLASS
     EXPRESSION ([pixel] < 25)
     COLOR 215 40 40
   END
   CLASS
     EXPRESSION ([pixel] < 100)
     COLOR 195 60 60
   END
   CLASS
     EXPRESSION ([pixel] < 250)
     COLOR 175 80 80
   END
   CLASS
     EXPRESSION ([pixel] < 1000)
     COLOR 165 100 100
   END
   CLASS
     EXPRESSION ([pixel] < 2500)
     COLOR 145 120 120
   END
   CLASS
     EXPRESSION ([pixel] < 10000)
     COLOR 125 140 140
   END
   CLASS
     EXPRESSION ([pixel] < 25000)
     COLOR 105 160 160
   END
   CLASS
     EXPRESSION ([pixel] <= 100000)
     COLOR 85 180 180
   END

Note that because the values between 0 and 100000 are classified
into only 64000 buckets you don't really have very good precision
at the bottom end of the range.  So even though we specify
[pixel] < 2.5, each bucket is about 1.5625 wide so the first two
buckets will get put into the first class, including values
between 2.5 and 3.125.  This imprecision will become insignificant
to a log scale as you move up to larger values.

Good luck,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent




More information about the MapServer-users mailing list