Reclassify (Spatial Analyst)
Resumen
Reclassifies (or changes) the values in a raster.
Uso
-
The input raster must have valid statistics. If the statistics do not exist, they can be created using the Calculate Statistics tool in the Data Management Tools toolbox.
-
If using the tool dialog box, the remap table can be stored for future use with the Save button. Use the Load button to open the remap tables you created previously with the Save button.
-
It is recommended to only load tables previously saved by the Reclassify tool. The table format is specific and must contain the fields FROM, TO, OUT, and MAPPING.
-
By default, the input raster will be classified into nine classes for the reclassification table.
-
If the input raster is a layer, the old values of the reclassification will be obtained from the renderer. If the renderer is stretched, the reclassification will default to 255 classes.
-
Once the remap table of the reclassification has been modified, the values will not be updated if a new input raster is selected. If the reclassification is not suitable for the new raster, a default reclassification can be reinitialized by:
- Editing or selecting a new value for the reclass field
- Restarting the tool
-
This tool has a precision control that manages how decimal places are treated.
-
When using the Reclassify tool as part of a model:
- If the input to the tool is derived data from a tool that isn't already run, the remap parameter in the Reclassify tool will be empty until the preceding tool is run and the model is validated. To avoid this, always run preceding tools before connecting their output variables as input to the Reclassify tool. Alternatively, you can create a custom reclassification table by adding entries.
- If exposing the reclassification table as a model parameter, the reclass field must be exposed as a variable. However, it does not need to be set as a model parameter. If the field is not exposed as a variable, the classify and unique values buttons will be disabled in the model tool dialog box.
Sintaxis
Parámetro | Explicación | Tipo de datos |
in_raster |
The input raster to be reclassified. | Raster Layer |
reclass_field |
Field denoting the values that will be reclassified. | Field |
remap |
The Remap object is used to specify how to reclassify values of the input raster. There are two ways to define how the values will be reclassified in the output raster; RemapRange and RemapValue. Either ranges of input values can be assigned to a new output value, or individual values can be assigned to a new output value. The following are the forms of the remap objects.
| Remap |
missing_values (Opcional) |
Denotes whether missing values in the reclass table retain their value or get mapped to NoData.
| Boolean |
Valor de retorno
Nombre | Explicación | Tipo de datos |
out_raster |
The output reclassified raster. The output will always be of integer type. | Raster |
Ejemplo de código
The following examples show several ways of several ways reclassifying a raster.
import arcpy from arcpy import env from arcpy.sa import * env.workspace = "C:/sapyexamples/data" outReclass1 = Reclassify("landuse", "Value", RemapValue([[1,9],[2,8],[3,1],[4,6],[5,3],[6,3],[7,1]])) outReclass1.save("C:/sapyexamples/output/landuse_rcls") outReclass2 = Reclassify("slope_grd", "Value", RemapRange([[0,10,"NODATA"],[10,20,1],[20,30,2], [30,40,3],[40,50,4],[50,60,5],[60,75,6]])) outReclass2.save("C:/sapyexamples/output/slope_rcls") outReclass3 = Reclassify("pop_density", "Value", RemapRange([[10,10,1],[10,20,2],[20,25,3], [25,50,4],[50,]]), "NODATA") outReclass3.save("C:/sapyexamples/output/popden_rcls")
This example reclassifies the input raster based on the values in a string field.
# Name: reclassify_example02.py # Description: Reclassifies the values in a raster. # Requirements: Spatial Analyst Extension # 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 = "landuse" reclassField = "LANDUSE" remap = RemapValue([["Brush/transitional", 0], ["Water", 1],["Barren land", 2]]) # Check out the ArcGIS Spatial Analyst extension license arcpy.CheckOutExtension("Spatial") # Execute Reclassify outReclassify = Reclassify(inRaster, reclassField, remap, "NODATA") # Save the output outReclassify.save("C:/sapyexamples/output/outreclass02")