Ticket #2181: [PATCH] Fix handling of NODATA values (for DTED files)

Even Rouault even.rouault at MINES-PARIS.ORG
Thu Jul 26 18:25:40 EDT 2007


[I've just copied/pasted the content of ticket #2181, as it might interest 
other users too]

Currently, when doing WCS on DTED files (whose NODATA value is -32767),
 you may experience problems when using INTERPOLATION=AVERAGE or
 INTERPOLATION=BILINEAR. That's because the NODATA value is not recognized
 as such and the resampling algorithms are using -32767 as a normal value,
 leading to 'fun' values like -16145 when computing averages. My proposal
 is to force the noData value as offsite.red when the source is a one band
 image.

 The following addition in msResampleGDALToMap fixes this :
 {{{
     if (srcImage->format->bands == 1)
     {
       void* hBand1 = GDALGetRasterBand( hDS, 1 );
       noData = msGetGDALNoDataValue( layer, hBand1, &bGotNoData );
       if (bGotNoData)
       {
         layer->offsite.red = noData;
       }
     }
 }}}

 But, this fix is not really sufficient to address the correct handling of
 DTED files. In aeraunatical applications using DTED files, the meaning of
 the NODATA value is really 'unknown', 'there's maybe a big mountain here
 but no data collected'. So, you often prefer the propagation of the
 uncertainty of the source to the result, rather than a clever
 interpolation that may be dangerous for the final user. So, if for some
 processing of an application, you need to resample a DTED Level 2 file to
 a lower resolution, like near the resolution of a DTED1 file, you want
 -32767 to be the result of the resampling as soon as one of source grid
 elements is -32767.
 With the small patch above, those source grid elements are just ignored
 for the computation.[[BR]]

 So, I've introduced a new PROCESSING directive ('STRICT_NODATA=YES') that
 enforces the propagation of the noData value. Of course, when using
 STRICT_NODATA=yes, you should also set 'LOAD_FULL_RES_IMAGE=YES' to be
 sure that all the source grid elements will be read. And of course, the
 default resampling method, NEAREST, doesn't make much sense... Debug
 warnings are emitted when those 2 conditions are not met.

 PS : I've a longer patch that adds another INTERPOLATION method, 'MAXIMUM'
 useful for aeronautical applications too (safety altitude computations for
 example). As its name suggests, it takes the maximum value of the source
 grid elements (except a noData value ;-)). As it depends of this current
 patch, I've thought that I should delay its posting.

 PS2 : It doesn't include the small patch I've previously sent for the
 reprojection/tileindex issue (http://trac.osgeo.org/mapserver/ticket/2180)



More information about the mapserver-users mailing list