Hot answers tagged

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

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

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

GetParameterAsText gets the value AS TEXT. Therefore a,b,c,d are all strings. You need to convert them to a numeric format before asking Con to compare them to x.


2

I think you want to use nested Con statements, like is described here to build your if-elif-else structure, instead of Con() | Con() | Con(). Instead of saying: Con(queryA, trueA, falseA) | Con(queryB, trueB, falseB) | etc... You should phrase it as: Con(queryA, trueA, Con(queryB, trueB, Con(...))) where the innermost Con() statement will have 0 as it's ...


2

This will list the raster names without full path/workspace: arcpy.env.workspace = r'C:/speed' speed = arcpy.ListRasters("*SPEED*","TIF") So when you change workspace afterwards, arcpy will not know where to find them. Try adding full path to the raster lists using os.path.join and list comprehension: import os arcpy.env.workspace = r'C:/speed' speed = ...


1

As you are not showing us the full code I can only guess as to the problem, you really should provide the full code, how do I even know you are importing the spatial analyst extension or setting the workspace? The answer is I don't. So I and the rest of the user community have to second guess what you actually did. So assuming you have written a script that ...


1

There is probably a more elegant way, but you can do this using Con, SetNull, and InList, which functions like the in conditional operator you were trying. Con(IsNull(InList("q530_prj_Clip.tif", [2800,2804,2808,2812,6896,6900,6904,6908,2976,2980,2984,2988,3008,3012,3016,3020,7072,7076,7080,7084,7104,7108,7112,7116,2752,2756,2760,2764,3008,3012,3016,3020,...


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