[mapserver-users] mapserver/gdal

Ed McNierney ed at topozone.com
Wed Oct 17 22:20:35 EDT 2001


Peter -

*IF* I'm reading the code right, it appears that MapServer will read a
GDAL single-band data set as 8-bit values by asking GDAL to provide the
data in 8-bit format.  GDAL will convert .bil data that's signed 16-bit
(Int16) to 8-bit by:

1. Returning 0 if the source pixel is <= 0.0
2. Returning 255 if the source pixel is >= 255.0
3. Returning the source pixel value in all other cases

In short, just clamping all values outside the range to either 0 or 255.

If you just want to do a quick hack, it would be REALLY easy to change
this behavior (or behaviour) to handle the pixel differently.  The
code's in the GDAL source in core/rasterio.cpp - look for the
GDALCopyWords function about 2/3rds of the way down the file.  You'll
have to figure out the proper conversion for your data, which would
depend on the range of input values and how you want to represent them.

Please remember that this message started with an *IF*, and if someone
could either confirm or correct what I'm saying I'd appreciate it.
Thanks!

	- Ed

Ed McNierney
Chief Mapmaker
TopoZone.com


-----Original Message-----
From: Peter deVoil [mailto:devoilp at dpi.qld.gov.au]
Sent: Wednesday, October 17, 2001 8:20 PM
To: mapserver-users at lists.gis.umn.edu
Cc: warmerdam at pobox.com
Subject: [mapserver-users] mapserver/gdal


Hi,
I'm using a recent (pre3.5) version of mapserver with gdal raster input
from 
esri .bil data. It's elevation in meters. It looks like
--------
$ gdalinfo elzeaa.bil 
Driver: EHdr/ESRI .hdr Labelled
Size is 600, 600
Coordinate System is `'
Origin = (165.000000,-25.000000)
Pixel Size = (0.008333,-0.008333)
Corner Coordinates:
Upper Left  ( 165.0000000, -25.0000000) 
Lower Left  ( 165.0000000, -30.0000000) 
Upper Right ( 170.0000000, -25.0000000) 
Lower Right ( 170.0000000, -30.0000000) 
Center      ( 167.5000000, -27.5000000) 
Band 1 Block=600x1 Type=Int16, ColorInterp=Undefined
  Min=-32768.000/0, Max=32767.000/0
  NoData Value=-9999
---------

I'm trying to build a classification for this and am unsure of how gdal
is 
mapping 2 byte values to 0:255 as the manual implies:
> " Some format drivers (ie. GDAL) cast the pixel values to the range
>  0 to 255 before applying the classification scheme to them,"

Am I correct that the high byte of elevation data is lost? This would
imply I have to convert Int16 -> unsinged char, and a pointer to a
method for this would be appreciated.

Yours,
PdeV.




More information about the mapserver-users mailing list