1

So I have an aspect raster that was created from a DEM. I'm trying to reclassify it using python, but I'm running into some issues. Here's the setup:

I need to reclassify values in the aspect raster that are between 315 and 360 to 1.2, between 0 and 45 to 1.2, between 135 and 225 to 0.8, and everything else to 1.0.

I've tried:

outAspect_Reclass = arcpy.sa.Reclassify(outAspect,"Value","0 44.99999 1.2;45 134.99999 1;135 224.99999 0.8;225 314.99999 1;315 360 1.2","NODATA")

And I've tried:

outAspect_Reclass = Float(Con((outAspect >= 0.0) and (outAspect <= 45.0), 1.2, Con((outAspect >= 135.0) and (outAspect <= 225.0), 0.8, Con((outAspect >= 315.0) and (outAspect <= 360.0), 1.2, 1.0))))

The first try fails because Reclassify won't reclassify to floats, and I'm not sure about the second try- can the Con() function do ranges (>=/<=)?

Can anyone tell me how to get this to work?

4
  • 1
    I believe your second attempt fails because Con uses the '&' operator, not 'and'. Otherwise, it should work.
    – phloem
    Commented Oct 14, 2014 at 22:15
  • if you can get a numpy representation of your raster, try this: gis.stackexchange.com/questions/116473/… Commented Oct 14, 2014 at 22:53
  • from the arcpy docs: arcpy.RasterToNumPyArray('path to raster file') will get you a numpy array, then use link above to reclassify it. And then call arcpy-raster = arcpy.NumPyArrayToRaster(my-numpy-raster) , then save it. Commented Oct 14, 2014 at 22:56
  • Possible duplicate: gis.stackexchange.com/questions/78245/…. I think you will find the answer here: gis.stackexchange.com/a/78344/8104
    – Aaron
    Commented Oct 14, 2014 at 23:00

1 Answer 1

1

As stated in the comments, the Con tool uses the '&' operator, not 'and'.

Edit: to clarify, 'and' also worked up until ArcGIS 9.3 (map algebra operators).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.