Slice (Spatial Analyst)
Slices or reclassifies the range of values of the input cells into zones of equal interval, equal area, or by natural breaks.
Slice works best on data that is normally distributed. When using input raster data that is skewed the output result may not contain all of the classes that you had expected or specified.
If an environment Mask has been set, those cells that have been masked will receive NoData on the output slice raster.
When using the EQUAL_AREA method, sometimes not all of the output classes will have an equal, or even similar, number of cells (i.e., area). This may be an inherent result based on the nature of the input values and the specified number of classes (bins). If the results are deemed undesirable, you can try using a few number of classes or applying a statistics transformation (e.g., logarithm, square root, and so on) to the input dataset.
The input raster to be reclassified.
The number of zones to reclassify the input raster into.
When the slice method is EQUAL_AREA, the output raster will have the defined number of zones, with a similar number of cells in each.
When EQUAL_INTERVAL is used, the output raster will have the defined number of zones, each containing equal value ranges on the output raster.
When NATURAL_BREAKS is used, the output raster will have the defined number of zones, with the number of cells in each determined by the class breaks.
The manner in which to slice the values in the input raster.
Defines the lowest zone value on the output raster dataset.
The default value is 1.
The output reclassified raster.
The output will always be of integer type.
Reclassify the input raster into five classes based on natural groupings inherent in the data.
import arcpy from arcpy import env from arcpy.sa import * env.workspace = "C:/sapyexamples/data" outslice = Slice("elevation", 5, "NATURAL_BREAKS") outslice.save("C:/sapyexamples/output/elev_slice")
Reclassify the input raster into ten classes based on natural groupings inherent in the data.
# Name: Slice_Ex_02.py # Description: Slices a range of values of the input cells of a raster by # zones of equal interval or equal area. # Requirements: Spatial Analyst Extension # Author: ESRI # Import system modules import arcpy from arcpy import env from arcpy.sa import * # Set environment settings env.workspace = "C:/sapyexamples/data" # Set local variables inRaster = "elevation" numberZones = 10 baseOutputZone = 5 # Check out the ArcGIS Spatial Analyst extension license arcpy.CheckOutExtension("Spatial") # Execute Slice outSlice = Slice(inRaster, numberZones, "NATURAL_BREAKS", baseOutputZone) # Save the output outSlice.save("C:/sapyexamples/output/outslice")