10

I'd like to use the QGIS Raster Style dialog to display modified raster values. Specifically, I'd like to see a gradient using the square root of the raster's value.

I understand it's possible to use the raster calculator to transform raster values, but - if possible - I'd like to skip that step and apply the mathematical formula during the styling, and avoid creating a modified copy of the original raster.

This type of operation is possible with vector files, using data defined values for colour/width/etc. Is it possible to do this with rasters?

2 Answers 2

3

I never try but it might possible by using Virtual raster file (VRT) create with GDAL on which you can perform calculation without modifying your datasource or create a huge new raster file on disk (just a vrt xml file that you can open in QGis and do you style on it's band values).

for exemple your vrt file should look like this (no tested):

<VRTDataset rasterXSize="1000" rasterYSize="1000">
    <VRTRasterBand dataType="Float32" band="1" subClass="VRTDerivedRasterBand">>
        <Description>Magnitude</Description>
        <PixelFunctionType>sqrt</PixelFunctionType>
        <SimpleSource>
            <SourceFilename relativeToVRT="1">yourraster.tiff</SourceFilename>
            <SourceBand>1</SourceBand>
            <SrcRect xOff="0" yOff="0" xSize="1000" ySize="1000"/>
            <DstRect xOff="0" yOff="0" xSize="1000" ySize="1000"/>
        </SimpleSource>
    </VRTRasterBand>
</VRTDataset>

To have more detail have a look to the Virtual format.

0

It's a good question. To my knowledge there's no way to do that for the moment, but I hope some day it will be possible.

As a temporary solution, you can try to convert your raster data to points and style them so they each look like boundaryless square of a size that equals the pixel spacing.

You can then use all vector styling tools you need on this "fake" pixel layer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.