[gdal-dev] -unscale issue with multiband vrt

Even Rouault even.rouault at mines-paris.org
Wed Dec 7 16:02:51 EST 2011


Le mercredi 07 décembre 2011 20:17:39, Kyle Shannon a écrit :

I think you are in fact exactly running in the issue of #3085.

It is difficult to know for sure without having the data under my eyes, but I'm 
going to guess one more time ;-)

So my guess it that before -unscale, your band 1 et 2 have pixels whose value 
match the nodata value of -9999. And they are not taken into account in the 
minimum/maximum value computation, which is appropriate.

After -unscale - that doesn't do special for nodata values - , those values of 
-9999 are multiplied by 100, hence the -999900 as the new minimum value for 
band 1 and 2. For other bands the minimum value after unscale is the minimum 
value before unscale * 100.

So all in all the behaviour is just consistant for all bands, but not the one 
you expect.


> Hi All,
> I am running into an issue with unscaling a multiband raster.  I am
> creating a vrt from 5 xyz datasets.  I use the following command:
> 
> gdalbuildvrt -separate -srcnodata -9999 mmi.vrt csv\*
> 
> 3 of the 5 rasters are of the lower 48 states of the US, the other 2 are
> only the western half.  gdalbuildvrt works good, and pads the eastern half
> of the US with nodata values of -9999 for the western rasters.  I have to
> scale all of the bands, so I edit the vrt and add <Scale>100</Scale> to
> each VRTRasterBand
> 
> This displays correctly in gdalinfo:
> 
> C:\Users\k\Desktop\mmi_tmp\vrt_test>gdalinfo -stats -nomd mmi.vrt
> Driver: VRT/Virtual Raster
> Files: mmi.vrt
>        csv\2008.WUS.Xpgv.537.2475
>        csv\2008.WUS.Xpgv.537.475
>        csv\UShazard.20081231.pga.10pc50
>        csv\UShazard.20081231.pga.2pc50
>        csv\UShazard.20081231.pga.5pc50
> Size is 1201, 509
> Coordinate System is `'
> Origin = (-125.025000000000010,50.024999999999999)
> Pixel Size = (0.050000000000000,-0.050000000000000)
> Corner Coordinates:
> Upper Left  (-125.0250000,  50.0250000)
> Lower Left  (-125.0250000,  24.5750000)
> Upper Right ( -64.9750000,  50.0250000)
> Lower Right ( -64.9750000,  24.5750000)
> Center      ( -95.0000000,  37.3000000)
> Band 1 Block=128x128 Type=Float32, ColorInterp=Undefined
>   Min=0.100 Max=200.000
>   Minimum=0.100, Maximum=200.000, Mean=10.363, StdDev=16.347
>   NoData Value=-9999
>   Offset: 0,   Scale:100
> Band 2 Block=128x128 Type=Float32, ColorInterp=Undefined
>   Min=0.100 Max=123.982
>   Minimum=0.100, Maximum=123.982, Mean=4.866, StdDev=8.152
>   NoData Value=-9999
>   Offset: 0,   Scale:100
> Band 3 Block=128x128 Type=Float32, ColorInterp=Undefined
>   Min=0.005 Max=1.110
>   Minimum=0.005, Maximum=1.110, Mean=0.041, StdDev=0.064
>   NoData Value=-9999
>   Offset: 0,   Scale:100
> Band 4 Block=128x128 Type=Float32, ColorInterp=Undefined
>   Min=0.005 Max=2.037
>   Minimum=0.005, Maximum=2.037, Mean=0.103, StdDev=0.150
>   NoData Value=-9999
>   Offset: 0,   Scale:100
> Band 5 Block=128x128 Type=Float32, ColorInterp=Undefined
>   Min=0.005 Max=1.346
>   Minimum=0.005, Maximum=1.346, Mean=0.063, StdDev=0.097
>   NoData Value=-9999
>   Offset: 0,   Scale:100
> 
> When I unscale the raster, the Full US bands do fine, but the no data value
> for the Western US Bands isn't respected and the nodata values are
> changed.  Am I missing something in my vrt?  Any thoughts.
> 
> C:\Users\k\Desktop\mmi_tmp\vrt_test>gdal_translate -unscale mmi.vrt mmi.tif
> Input file size is 1201, 509
> 0...10...20...30...40...50...60...70...80...90...100 - done.
> 
> C:\Users\k\Desktop\mmi_tmp\vrt_test>gdalinfo -nomd -stats mmi.tif
> Driver: GTiff/GeoTIFF
> Files: mmi.tif
> Size is 1201, 509
> Coordinate System is `'
> Origin = (-125.025000000000010,50.024999999999999)
> Pixel Size = (0.050000000000000,-0.050000000000000)
> Corner Coordinates:
> Upper Left  (-125.0250000,  50.0250000)
> Lower Left  (-125.0250000,  24.5750000)
> Upper Right ( -64.9750000,  50.0250000)
> Lower Right ( -64.9750000,  24.5750000)
> Center      ( -95.0000000,  37.3000000)
> Band 1 Block=1201x1 Type=Float32, ColorInterp=Gray
>   Minimum=-999900.000, Maximum=20000.000, Mean=-582357.045,
> StdDev=493551.313 NoData Value=-9999
> Band 2 Block=1201x1 Type=Float32, ColorInterp=Undefined
>   Minimum=-999900.000, Maximum=12398.200, Mean=-582586.370,
> StdDev=493279.394 NoData Value=-9999
> Band 3 Block=1201x1 Type=Float32, ColorInterp=Undefined
>   Minimum=0.500, Maximum=111.030, Mean=4.092, StdDev=6.447
>   NoData Value=-9999
> Band 4 Block=1201x1 Type=Float32, ColorInterp=Undefined
>   Minimum=0.500, Maximum=203.720, Mean=10.284, StdDev=14.961
>   NoData Value=-9999
> Band 5 Block=1201x1 Type=Float32, ColorInterp=Undefined
>   Minimum=0.500, Maximum=134.630, Mean=6.273, StdDev=9.686
>   NoData Value=-9999
> 
> 
> 
> Kyle Shannon
> Senior Software Engineer
> GCS Research
> Office 406-532-3254 * Direct 406-541-3276
> kshannon at gcs-research.com<mailto:kshannon at gcs-research.com> *
> www.gcs-research.com<http://www.gcs-research.com/>


More information about the gdal-dev mailing list