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?

GISUser9
  • 825
  • 11
  • 24
  • 1
    I believe your second attempt fails because Con uses the '&' operator, not 'and'. Otherwise, it should work. – phloem Oct 14 '14 at 22:15
  • if you can get a numpy representation of your raster, try this: http://gis.stackexchange.com/questions/116473/reclassify-rasters-using-gdal-and-python/118174#118174 – user1269942 Oct 14 '14 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. – user1269942 Oct 14 '14 at 22:56
  • Possible duplicate: http://gis.stackexchange.com/questions/78245/how-can-i-reclassify-an-integer-raster-to-a-float-raster. I think you will find the answer here: http://gis.stackexchange.com/a/78344/8104 – Aaron Oct 14 '14 at 23:00

1 Answers1

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).

phloem
  • 4,678
  • 15
  • 30