Hello,
I am using ArcGis 10.2. I have 3 classified rasters and i want to use the following query from r. calculator:
(rclslope>=45) & (rclmosaic>=2000) & (rclfocal>15) to arc.py
how can i write it?
Is it better to use local - combine tool with arc.py to do it?
Thank you very much.
You could use the Con tool (see this page for relevant examples):
Con(("rclslope">=45)&("rclmosaic">=2000)&("rclfocal">15),1)
This returns a raster with pixel value = 1 which meets the criteria. If you're looking for a way to spatially query pixel values in ArcGIS, that doesn't exist to my knowledge.
thanks a lot Mr. Darren Wiens. But i need a little more help if you can. The entire code should seem like;
There are lots of arcpy examples using Con here - scroll to the bottom.
So we mean something like that?
import arcpy
from arcpy import env
from arcpy.sa import *
env.workspace = "C:/sapyexamples/data"
outCon = Con(("rclslope">=45)&("rclmosaic">=2000)&("rclfocal">15),1)
outCon.save("C:/sapyexamples/output/outcon")
Because with that i get an error
well the error would help and you should have spaces between the grid names and the operands and perhaps it can't find the grids (assumed since there are no file extensions) And the big one is that you didn't make raster objects from you grid names. and please tell me that you have a path called c:/saexamples to test it in.
env.workspace = "C:/sapyexamples/data"
inRas1 = Raster("inRaster")
inRaster is inside the path
inRas1 is a Raster object which is needed by the Con statement
Agreed, mostly. What's this about spaces? AFAIK, they are irrelevant.
Mr. Patterson i think i cannot understand you very well. I am still new in programming.
Please post the error.