Remap

摘要

将栅格对象的像素值分类为具有特定值的组。

例如,分配 1 到 25 的图像值 1,分配 200 到 255 的图像值分 255。

说明

有关此函数工作原理的详细信息,请参阅重映射栅格函数。

栅格对象所引用的栅格数据集是临时性的。 要将其设置为永久,可以调用栅格对象的 save 方法。

语法

Remap (raster, {input_ranges}, {output_values}, {no_data_ranges}, {allow_unmatched})
参数说明数据类型
raster

The input raster.

Raster
input_ranges

Input ranges are specified in pairs: from (inclusive) and to (exclusive).

(默认值为 None)

Double
output_values

Output values of corresponding input_ranges.

(默认值为 None)

Double
no_data_ranges

NoData ranges are specified in pairs: from (inclusive) and to (exclusive).

(默认值为 None)

Double
allow_unmatched

Missing values in the reclass table can retain their value or be remapped to NoData.

  • True—Any pixel from the input raster that does not get reclassed in a remap table will retain its value and be written for its location to the output raster.
  • False—Any pixel from the input raster that does not get reclassed in a remap table will have its value remapped to NoData for its location to the output raster.

(默认值为 True)

Boolean
返回值
数据类型说明
Raster

输出栅格。

代码示例

重映射示例 1

本示例将对输入栅格重新分类。

from arcpy.ia import *
out_remap_raster = Remap("NomalRaster.tif")
out_remap_raster.save("C:/arcpyExamples/raster_remap.tif")
重映射示例 2

本示例将对输入栅格重新分类。

# Import system modules
import arcpy
from arcpy.ia import *

# Set the analysis environments
arcpy.env.workspace = "C:/arcpyExamples/data"

# Set Local Variables
in_raster = "raster.tif"

# Excute Remap function
out_remap_raster = Remap(in_raster, [-5, 0, 0, 5], [-1, 1])

# Save output
out_remap_raster.save("C:/arcpyExamples/outputs/raster_remap.tif")