TransWikia.com

Transposing raster values on the fly in QGIS

Geographic Information Systems Asked on April 12, 2021

Say, I have a raster with some annual statistics data.

Then

Daily avg = Annual / 365
Weekly avg = Annual / 52
Monthly avg = Annual / 12

I know I can do this via Raster calculator in QGIS (v2.18.15). However, there is always a new output. Therefore I am looking for more convenient to do it on-the-fly. Is there some tool to manipulate raster data settings?

For vector data, there is Query builder (in Layer Properties -> General) to exclude or manipulate the dataset (which is not exactly the same, but does a great job with data).

One Answer

After some time I found a partial solution to this via building a VRT file (see more specification) and setting the

<scale>
<offset>

+ some more can be added in

<ComplexSource>

Example of DEM scaled from [m] to [ft]

<VRTDataset rasterXSize="800" rasterYSize="800">
  <SRS>GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433],AUTHORITY["EPSG","4326"]]</SRS>
  <GeoTransform> -6.2000000000000000e+01,  2.5000000000000001e-03,  0.0000000000000000e+00,  1.5000000000000000e+01,  0.0000000000000000e+00, -2.5000000000000001e-03</GeoTransform>
  <Metadata>
    <MDI key="AREA_OR_POINT">Area</MDI>
  </Metadata>
  <VRTRasterBand dataType="Int16" band="1">
    <NoDataValue>nan</NoDataValue>
    <ColorInterp>Gray</ColorInterp>
    <scale>3.28084</scale>
    <SimpleSource>
      <SourceFilename relativeToVRT="1">DEM_meters.tif</SourceFilename>
      <SourceBand>1</SourceBand>
      <SourceProperties RasterXSize="800" RasterYSize="800" DataType="Int16" BlockXSize="800" BlockYSize="1" />
      <SrcRect xOff="0" yOff="0" xSize="800" ySize="800" />
      <DstRect xOff="0" yOff="0" xSize="800" ySize="800" />
    </SimpleSource>
  </VRTRasterBand>
</VRTDataset>

Unfortunatelly, it seems that GDAL has not good support to write into VRT (I add this line to XML manually). There is some promising feature from just released GDAL2.3 in

gdal_translate -a_scale ...

(still to be tested, yet)

Answered by jurajb on April 12, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP