9

Try this syntax: (A@1 = 3 + A@1 = 11)* A@1 + B@1 @1 means the first band of the raster A@1 = 3 returns 1 (TRUE) if A is 3 When A is 3 or 11, (A@1 = 3 + A@1 = 11) part returns 1. Otherwise it returns 0.


4

From Raster Calculator help... The Raster Calculator tool is intended for use in the application only as a GP tool dialog box or in ModelBuilder. It is not intended for use in scripting and is not available in the ArcPy Spatial Analyst module. So, using the Math toolset, break your expression down in to its component parts, then save the result. ...


3

Zonal Statistics used to be a plugin, but it's now located in the Processing Toolbox (screenshot from QGIS 3.6). Many tools which were originally created as external plugins, were later incorporated into the core QGIS program. In general if you're following a tutorial created in an earlier version of QGIS and you can't find a tool mentioned in the tutorial, ...


3

The error tells you exactly what is wrong and where IndentationError: expected an indented block (line 7). You need to indent lines in your if clause: if value > 1: outraster = (f1 + f2 + f3)/3 else: outraster = (f1 + f2 +f3)/3 - 1 However, this code won't do what you want it to. You need to use Con: f123 = f1 + f2 + f3 outraster = Con(f123 >...


3

Try converting your rasters to numpy arrays, build a classifying function and convert resulting Array back to raster. (This way you dont need Spatial Analyst extension) Example with two random rasters with values from 0-1. Modify the function etc: import numpy as np import arcpy raster1 = "randraster_1" #Change raster2 = "randraster_2" #Change ...


3

You can use the following expression in the raster calculator: (("LayerName@1" = 0) AND (("LayerName@1" = 1) - 1)) Example, The input Test data has a pixel values of 0 and 1. Running the above equation as follows: (("Test@1" = 0) AND (("Test@1" = 1) - 1)) It produced the following result:


3

You're specifying the function instead of calling it. I.e. layer1.extent should be: layer1.extent() Do this with width and height: calc = QgsRasterCalculator(exp, output, 'GTiff', layer1.extent(), QgsCoordinateReferenceSystem("EPSG:3003"), ...


3

SAGA For the SAGA raster calculator, you can set the Formula option to read the value from your Number Input parameter: In the Formula option, set the drop-down menu to Pre-calculated Value. The first layer is defined by the string 'a'. So if you want to take the original values from the first raster layer and add the value from the Number Input parameter, ...


3

If you want to get the matching rasters you can zip both lists so you iterate over a list of tuples containing two rasters (one red, one nir) at a time. for rotesband, nirband in zip(liste_rotesband,liste_nirband): print 'red band: {}'.format(rotesband) print 'nir band: {}'.format(nirband) Regarding your edit, you are attempting to use the Float() ...


2

The problem is the formula or let's say how you build it. try to build it like this: formula = 'a-{}'.format(Hoehe) outputs_SAGARASTERCALCULATOR_1=processing.runalg('saga:rastercalculator', Input_Raster,[],formula,0,False,7,Rasterout)


2

you can also use the raster calculator, but it quickly creates long statement Map algebra > raster calculator, for example : Con(("sand" > 90) and ("clay" <10 ), 1, Con(("silt">50) and ("clay"<30),2,3) The syntax is Con (condition, value if true, value if false)


2

I'd like to provide an alternative answer/example using GDAL: raster calculator, updated for QGIS 3. If you look in the 'processing' toolbox then GDAL > Raster Miscellaneous > Raster calculator you'll find the GUI tool. I like to test using the GUI tool first before I write the code. First, you can call the help docs for this tool using: processing....


2

You should use capital letters for the RESULT which is the Key in the dictionary 'Differenzen': Pos_Differenzenalg=processing.runalg('saga:rastercalculator', Differenzen['RESULT'],[],'a*(a>0)',0,False,7,Pos_Differenzen)


2

Try this piece of code. I do not think that you have to cast the mean/std to float. Try it out this way. Of course you need an Spatial Analyst, but since you are using RasterCalculator I think you have it. import arcpy from arcpy.sa import * arcpy.CheckOutExtension('Spatial') ws2 = r"C:\unsupervised_classification\output\raster_tagliati_su_flowacc" ...


2

I think it is a bug in QGIS 3.6, if you load the raster into QGIS 3.4.5 Long Term Release (LTR), it will be loaded correctly with all the bands available in single raster: QGIS 3.4.5 LTR: QGIS 3.6: You can report a bug following this page here: Bugs, Features and Issues. My advice is to use QGIS 3.4.5 LTR as it is a stable version.


2

Con is an ArcGIS raster tool which is not available in QGIS. If you want to replace all 0 value cells with nodata, you could use something like: ("demclip_re@1") / ("demclip_re@1">0)


2

Quoting example three from the documentation, proper use of Con includes a final step: import arcpy from arcpy import env from arcpy.sa import * env.workspace = "C:/sapyexamples/data" inRaster1 = Raster("landuse") inRaster2 = Raster("landuse2") outCon = Con(((inRaster1 == 1) & (inRaster2 == 5)), inRaster1 + inRaster2, 99) outCon.save("C:/sapyexamples/...


2

You can control the cell size from the ArcToolbox -> Geoprocessing Environment -> Cell size. Also another way to sum all rasters is to use Cell Statistics tool with SUM type for such a task. Here is an illustration from the help page:


2

Use the Python Console and enter the following with your defined path: QSettings().setValue("/RasterCalculator/lastOutputDir", "myOutputPath") This will remain the default path even after you restart QGIS.


2

Use the Cell Statistics tool : Calculates a per-cell statistic from multiple rasters. The available statistics are Majority, Maximum, Mean, Median, Minimum, Minority, Range, Standard deviation, Sum, and Variety. Use the SUM statistic and ensure Ignore NoData is ticked and set the output extent environment to Union of inputs


2

The raster calculator creates a new layer. The calculations aren't stored in the new layer; only the result of the calculation is stored. To modify the calculation, you have to re-run the calculator. The good news is that since QGIS 3, most processing algorithms stay open after you run them, with all their settings intact. So if you don't close the raster ...


2

cvr_rasters will be a list of only raster names with no path/workspace. When you change workspace after it is created the rasters will not be found. Try adding path to each raster: ... arcpy.env.workspace = CVR cvr_rasters = arcpy.ListRasters() cvr_rasters = [os.path.join(CVR, r) for r in cvr_rasters] ... Same goes for lss_rasters since you change ...


2

ArcGIS Help description of the error is the following: This is an operating system error and can indicate different error conditions. These errors are not specifically documented in the ArcGIS Desktop Help system. However, in most cases, the error description provided with the error code can be used to look up additional information on the ...


2

a more compact writing could be B*(A==1)*((B==10)+(B==11)+...+(B==800)) but this would still be quite long. For me, any is not the good command but you could use isin (not tested) B*(A==1)*(isin(B,[10,11,...,800]))


2

I don't think you can embed a GRASS module into an r.mapcalc expression. The way to accomplish with GRASS what you have shown in the ArcGIS raster calculator would require two steps, using a mask, as follows: # As always, set the computational region g.region -ap rast=rater3 # Determine the mask # Note that the GRASS logical AND operator is && r....


2

I just needed the raster calculator. Here is what I put in the equation: HWE - "DEM@1" where: HWE = value of high water elevation at same vertical datum and units as DEM raster (e.g. 44) DEM = the file name of the DEM layer which I used


2

I've just managed to get the model working. The issue is caused by a glitch of some sort, related to the system language. After changing the QGIS language from Spanish to English, the model above works with no issues. Will report this on the QGIS github. (bug report) It's not the first time I've run across issues during some process due to the language, ...


2

Don't use quote symbols around numeric variables. Using quotes includes the values as strings! So, where you have 10000 * "%Soil Depth (m)%", this is equivalent to saying 10000 * "0.05". NOT 10000 * 0.05. When you multiply a string by 10,000, you get that string concatenated to itself, 10,000 times! Something like: 0.050.050.050.050.050.050.050.050.050....


2

This is untested as I'm not at work, but I would do something like this: from arcpy.sa import * input_raster = 'path/to/raster' red = Float(Raster(input_raster + r"\Band_3")) nir = Float(Raster(input_raster + r"\Band_4")) ndvi = (nir - red) / (nir + red) ndvi.save("ndvi_result")


1

Instead of using the raster calculator you could reclassify your raster bands. This tread lists a few options: How to reclass a raster with reclassify grid values in QGIS? Inside QGIS you can use the GRASS module r.reclass. Reclassifying rules have to be specified in a text file or directly. I am not sure if this works directly for all bands or if you have ...


Only top voted, non community-wiki answers of a minimum length are eligible