[mapserver-users] Mathematical Scaling of Floating Point Data in Mapserver Map File
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? Thanks, Peter ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
Re: [mapserver-users] Mathematical Scaling of Floating Point Data in Mapserver Map File
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,10 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] 1) COLOR 125 140 140 END CLASS EXPRESSION ([pixel] 25000) COLOR 105 160 160 END CLASS EXPRESSION ([pixel] = 10) COLOR 85 180 180 END Note that because the values between 0 and 10 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, warmer...@pobox.com light and sound - activate the windows | http://pobox.com/~warmerdam and watch the world go round - Rush| Geospatial Programmer for Rent ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
Re: [mapserver-users] Mathematical Scaling of Floating Point Data in Mapserver Map File
Thanks Frank, That helps somewhat. It's going to be a bit of a bear making a 256 color lookup that way. I guess I can script the CLASS lookup sections of the map file(s). Peter Frank Warmerdam wrote: 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,10 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] 1) COLOR 125 140 140 END CLASS EXPRESSION ([pixel] 25000) COLOR 105 160 160 END CLASS EXPRESSION ([pixel] = 10) COLOR 85 180 180 END Note that because the values between 0 and 10 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, ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
Re: [mapserver-users] Mathematical Scaling of Floating Point Data in Mapserver Map File
Frank Warmerdam wrote: There isn't anything magical about 256. 256 or better raster scales sure are pretty though :) Seriously though, the raster data is floating point log data with relatively random spatial distribution. Short of making two images, one log float and one anti-log float, it would be nice to be able to scale on the fly without duplicating the original data. Duplication of rasters is O.K. if you have one or two, but once you near the 30k-40k files mark the disk space becomes a tad expensive. Would it be out of line to suggest some scaling functions like the generic math functions: log log10 sin asin sinh cos acos cosh tan atan tanh abs sqrt mod Peter ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
Re: [mapserver-users] Mathematical Scaling of Floating Point Data in Mapserver Map File
Peter Willis wrote: Frank Warmerdam wrote: There isn't anything magical about 256. 256 or better raster scales sure are pretty though :) Seriously though, the raster data is floating point log data with relatively random spatial distribution. Short of making two images, one log float and one anti-log float, it would be nice to be able to scale on the fly without duplicating the original data. Duplication of rasters is O.K. if you have one or two, but once you near the 30k-40k files mark the disk space becomes a tad expensive. Would it be out of line to suggest some scaling functions like the generic math functions: log log10 sin ... Peter, I understand your point, but I remain somewhat hesitant to build it a lot more complexity into the floating point handling for display. Best regards, -- ---+-- I set the clouds in motion - turn up | Frank Warmerdam, warmer...@pobox.com light and sound - activate the windows | http://pobox.com/~warmerdam and watch the world go round - Rush| Geospatial Programmer for Rent ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users