[gdal-dev] Having a problem getting VRT ComplexSource to Scale

Stephen Woodbridge stephenwoodbridge37 at gmail.com
Thu Jan 23 17:20:16 PST 2020


Hi all,

I'm having trouble getting my VRT file to scale the source data into my 
ColorTable.
I've been looking at this https://gdal.org/drivers/raster/vrt.html

The source GeoTiff has:

Band 1 Block=4500x1 Type=Float32, ColorInterp=Gray
   Minimum=1.082, Maximum=46.322, Mean=34.181, StdDev=2.049
   NoData Value=-30000
   Overviews: 2250x2126, 1125x1063, 563x532, 282x266, 141x133, 71x67
   Metadata:
     STATISTICS_MAXIMUM=46.321998596191
     STATISTICS_MEAN=34.181107349018
     STATISTICS_MINIMUM=1.0819988250732
     STATISTICS_STDDEV=2.0492649377546

My goal is to scale the source 0-50 into 10-240 in the ColorTable.


The VRT looks like:

<VRTDataset rasterXSize="4500" rasterYSize="4251">
   <GeoTransform> -180.0 ,0.08 , 0 , 90.0 , 0 , -0.04 </GeoTransform>
   <Metadata>
   </Metadata>
   <VRTRasterBand dataType="Byte" band="1">
     <ColorInterp>Palette</ColorInterp>
     <ColorTable>
       <Entry c1="0" c2="0" c3="0" c4="255"/>
       <Entry c1="0" c2="0" c3="255" c4="255"/>
...
       <Entry c1="255" c2="255" c3="255" c4="255"/>
     </ColorTable>
     <ComplexSource>
       <SourceFilename 
relativeToVRT="1">HYCOM_tomorrow_salinity_0.tif</SourceFilename>
       <SourceBand>1</SourceBand>
       <ScaleOffset>0</ScaleOffset>
       <ScaleRatio>1</ScaleRatio>
       <NODATA>0</NODATA>
       <SrcRect xOff="0" yOff="0" xSize="4500" ySize="4251"/>
       <DstRect xOff="0" yOff="0" xSize="4500" ySize="4251"/>
     </ComplexSource>
   </VRTRasterBand>
</VRTDataset>

50 - 0 = 50
240 - 10 = 230
230 / 50 = 4.6 = ScaleRatio
10 = ScaleRatio

I've tried a lot of other value trying to play with the scaling.

I also tried using:

<Exponent>0</Exponent>

<SrcMin>0</SrcMin>
<SrcMax>50</SrcMax>
<DstMin>10</DstMin>
<DstMax>240</DstMax> but that doesn't appear to work either. Using: GDAL 2.2.3, 
released 2017/11/20 on Unbuntu 18.04 My conclusion is that I'm not 
understanding the meaning of these fields or these are meant for 
something other than my goal. Any help would be appreciated. Thanks, -Steve



More information about the gdal-dev mailing list