I get this same error when I try to write the raster calculator output to a network path that is too long and/or contains an odd character. When I write the output to my C: drive it works okay. The specific errors are the references to line 1, line, 8 and "could not save".
One solution is to write it to your C drive and then export it to the place that you ...
The solution I found was to use the SAGA PATCHING algorithm. This tool takes a raster that has pixels you want to replace in another raster. All nodata pixels in the input raster will become the value of the target raster and all pixels with a value in the input raster keep their values. Essentially replacing the values in the target raster. (I'm using QGIS ...
Let's say your DEM layers have the names DEM1 and DEM2.
The following expression (in the QGIS Raster Calculator) returns 0 for the differences that have an absolute value that is less than 0.005, and the calculated difference larger absolute differences:
"DEM1@1" - "DEM1@1" * (("DEM1@1" - "DEM1@1" > 0.005) OR ("DEM1@1" - "DEM1@1" < -0.005))
While I can't test or verify without information on how the original data was processed, my guess is that there are default CRS values that differ slightly in QGIS from the software where your original raster was created.
I've had issues between FME and ArcGIS before where reprojections of the same data using the same settings yielded very slightly ...
This sounds like the Raster Calculator's output extent, resolution, and CRS do not match your input layer's. QGIS is therefore carefully resampling the input layer to generate the output layer with the "wrong" lattice structure.
Make sure you invoke the the Raster Calculator with the input layer, in your case bathymetry, selected; not another layer with ...
When you are using the Raster Calculator tool, make sure you are setting the Cell size, Output extent, and Output CRS to the same as the reference layer. If you are unsure of the cell size of the reference layer, you can leave that blank, but make sure to set the other two settings to the same as the reference layer. This should provide you a 1:1 match ...
in the raster calculator, the symbol "^" is a boolean operator, not the power function.
For the square values, you should either use the Power() function or the equivalent operator **
"prec_1" ** 2
In addition, make sure that you work in float, before your percentages could be rounded to zero before you multiply by 100.
Yes. Raster objects have a maximum property. Just make sure statistics have been calculated for the raster or maximum will return None.
Con("my_raster.tif" > "other_raster.tif".maximum, value_if_true, value_if_false)
You could use the MAXIMUM argument in arcpy.GetRasterProperties_management() to get the highest cell value in the raster. See the documentation for Get Raster Properties (Data Management).
eg, x = arcpy.GetRasterProperties_management("udlen", "MAXIMUM")
Is that what you're after?
Not the most efficient, but the easiest way is to
first, run the expand tool on your agricultural cells
second, run the raster calculator to find pixels of the original raster that overlap agricultural pixels in the expanded raster.
In commands, that would give something like this (assuming that your integer values for agri = a1 or a2 and forest = f1 ...
The description of the -a_nodata parameter from the documentation of gdal_translate https://gdal.org/programs/gdal_translate.html
Assign a specified nodata value to output bands. It can be set to none to avoid setting a nodata value to the
output file if one exists for the source file. Note that, if the input
dataset has a ...
If you want to set pixels to null when "MyRaster" >= 2800 and set everything else to the values of "MyRaster" all in one step, use this expression:
Con("MyRaster" < 2800, "MyRaster")
or this expression:
SetNull("MyRaster" >= 2800, "MyRaster")
Regarding the 2nd part of your question (the conversion): unfortunately, while QGIS has functions that manipulate colours in expressions (see https://docs.qgis.org/testing/en/docs/user_manual/working_with_vector/expression.html#color-functions), those expressions work on vector layers and not in the raster calculator, which is implemented differently.