Thanks for the answers! However, I somehow still don't get it running. I also made sure to clip the rasters to the same extent. If I am only doing calculations with one layer, the script works, but if I want to calculate with two layers, I don't receive any output (but also no error messages).
Any ideas? Thanks!
The easiest way to turn negative to corresponding positive values in raster calculator without even using a conditional statement is simply the function abs():
ABS ( "DEM@1" )
See result for the area of the Jordan valley and the Dead Sea (red ouline) that is changed to positive values, whereas the rest remains: left - original DEM, right - output ...
Here's a stab at solving this. For the east-west case (north-south is essentially the same): An image where each pixel represent the distance to the point is combined with the LST band, pixels not on the east-west line are masked out, and features with distance and LST are created for every non-masked out pixel.
var image = lstAdded_2019.first().select('LST')...
For QGIS versions older than 3.22, you can create a conditional statement for what you want to do with this expression:
("DEM@1" < 0) * (-1) * "DEM@1" + ABS ( ("DEM@1" < 0) - 1) * "DEM@1"
100 -> 100
2 -> 2
-5 -> 5
-150 -> 150
In previous versions it simply performs an assignment, a conditional within a parenthesis followed by a *, performs an assignment to all pixels that meet that condition.
("DEM" < 0 ) *0 + ("DEM" >= 0 ) *"DEM"
It will convert all values less than 0 to 0, and leave all other pixels the same.
On the other hand, if ...
Your Acreage field is simply an attribute you created and tagged onto the end of the raster attribute table. It is Value field in the raster dataset that holds the value of the pixel. To replace the pixel value to the value held in the Acreage field you need to do the following:
Export the attribute table of your Raster1 dataset to a stand alone table, e.g. ...
gdal_calc uses python syntax. In python = is used for variable assignment and == is for equality checking.
>>> a = 123
>>> a == 123
>>> a == 1234
So the following should work:
gdal_calc --calc "(A == 0) * B + (A != 0) * A" --format GTiff --type Float32 -A C:\Users\Public\try\...
Use the Raster Calculator tool with the Con and IsNull functions to set the output raster to the existing landuse value where proposed landuse is null, otherwise set to 9.
Note: make sure you set the tool environment processing extent and snap raster if the rasters have different dimensions.
Con(IsNull("PROPOSED"), "LANDUSE", 9)