Hi,
I have one raster and would like to transform all values between -0,9 - 0 like 1 value, and 0 - 0,9 like NoData.
How can I to this in python?
Thank´s
Reclassify (Spatial Analyst)—ArcGIS Pro | Documentation
See the code examples for the spatial analyst extension.
Have you used the arcpy.ddd.Reclassify tool yet?
From the docs:
import arcpy
# Set Environment
arcpy.env = r"<PATH TO ENVIRONMENT>"
# Set local variables
inRaster = "landuse"
field = "VALUE"
remapString = "1 9;2 8;3 1;4 6;5 3;6 2;7 1"
outRaster = "C:/output/reclass3d"
# Execute Reclassify
arcpy.ddd.Reclassify(inRaster, field, remapString, outRaster, "DATA")
In your case you would do something like this:
import arcpy
arcpy.env = r"<PATH TO ENVIRONMENT>"
remap = "-0.9 0 1"
raster = r"<PATH TO RASTER>"
field = "<RECLASS FIELDNAME>"
out_raster = r"<PATH TO OUTPUT RASTER>"
arcpy.ddd.Reclassify(raster, field, remap, out_raster, "NODATA")
The "NODATA" flag at the end will write any values outside the provided remap range with NoData instead of the original values, so in your case you only define the remap for the lower end and just don't map the values over 0
If you want ESRI to set the classes for you using some good algorithms you can try Slice https://pro.arcgis.com/en/pro-app/latest/tool-reference/spatial-analyst/slice.htm