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
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
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
Reclassify (Spatial Analyst)—ArcGIS Pro | Documentation
See the code examples for the spatial analyst extension.
サインインしたメンバーは投稿、更新のフォローなどができます。初めてですか?無料アカウントを登録してください。
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.