RemapValue (arcpy.sa)

摘要

该列表用于将各输入值重分类为各输出栅格所对应的值。

插图

RemapValue 重映射表图像
重分类功能的 RemapValue 重映射表。

讨论

RemapValue 对象可用于重分类工具和 WOTable 类中。

通过输入 NoData(字符串)作为新值,可为 NoData 赋予旧值

各输入值为分类值(如土地利用)或者仅需更改少量值时,通常使用按单个值进行重分类。

语法

RemapValue (remapTable)
参数说明数据类型
remapTable
[[oldValue, newValue],...]

The remap table to be used to remap the old values to new values.

It defines a list to be used to remap the input values. It is a list of lists, with the inner lists being composed of two components.

The components are:

  • oldValue—Represents an original value from the base raster (data type: double, long, string).
  • newValue—Is the new reclassified value (data type: long).

The oldValue can be numeric or string. The newValue must be integer.

List

属性

属性说明数据类型
remapTable
(读写)

The remap table that is used to remap the original values to new values.

List

代码实例

RemapValue 示例 1(Python 窗口)

演示如何创建 RemapValue 类并在 Python 窗口中的 Reclassify 工具中使用 RemapValue 类。

import arcpy
from arcpy import env
from arcpy.sa import *
env.workspace = "C:/sapyexamples/data"
myRemapValue = RemapValue([["Water", 0], ["Wetlands", 0], ["Barrenland", 1], ["Brushtransitional", 2], ["Builtup",3]])
outReclassRV = Reclassify("landuse", "LANDUSE2", myRemapValue)
outReclassRV.save("C:/sapyexamples/output/reclassrv")
RemapValue 示例 2(独立脚本)

使用 RemapValue 类进行重分类。

# Name: RemapValue_Ex_02.py
# Description: Uses the RemapValue object to execute Reclassify tool.
# 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 = "negs"

# Define the RemapValue Object
myRemapVal = RemapValue([[-3,9],[0,1],[3,-4],[4,5],[5,6],[6,4],[7,-7]])

# Check out the ArcGIS Spatial Analyst extension license
arcpy.CheckOutExtension("Spatial")

# Execute Reclassify
outReclassRV = Reclassify(inRaster, "VALUE", myRemapVal, "")

# Save the output 
outReclassRV.save("C:/sapyexamples/output/reclassrevar2")

相关主题

5/10/2014