Render

摘要

通过将符号系统应用于引用的栅格数据集来创建渲染的栅格对象。 在 Jupyter 笔记本中显示数据时,此函数很有用。

说明

使用 Render 函数修改栅格对象的显示以改进符号系统。 在使用 Jupyter Notebook 工作时,此函数很有用,因为数据显示对 Notebook 环境至关重要。

该函数可创建应用了渲染规则或色彩映射表的栅格对象。 必须至少指定一个渲染规则或色彩映射表。

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

生成的栅格数据集将包含已应用该函数的渲染规则。

语法

Render (in_raster, {rendering_rule}, {colormap})
参数说明数据类型
in_raster

The input raster dataset.

Raster
rendering_rule

The rendering rules to apply to the input raster. If a color map is not specified, a rendering rule must be specified.

The rendering rules can use one or more of the following formats:

  • bands—A list of band indexes to be mapped to an RGB display.

    For example, to create a natural color composite for Landsat 8 imagery, where band 4 is displayed as red, band 3 as green, and band 2 as blue, use {'bands': [4, 3, 2]}.

  • min and max—A range of values to use to perform a linear stretch on the raster. The minimum and maximum values are used as endpoints for the histogram stretch, and they can be single inputs or a list of values, one pair per band.

    For example, to perform a linear stretch from pixel value 0 to 100 for a single-band raster, use {'min': 0, 'max': 100}. To perform a linear stretch on a three-band image where each will stretch from a pixel value of 0 to different maximum pixel values, use {'min': 0, 'max': [220,210,180]}.

  • numberOfStandardDeviations—A single value that describes the number of standard deviations to use for a linear stretch. The stretch will be applied between minimum and maximum pixel values defined by the number of standard deviations from the mean.

    For example, to perform a linear stretch that removes any pixel values beyond two standard deviations from the mean, use {'numberOfStandardDeviations': 2}.

  • gamma—A single value or a list of values (one per band) that defines the amount of gamma correction to apply to control the overall brightness of the raster display. Gamma can also impact the ratios of red to green to blue in the display.

    For example, to perform a gamma stretch of 0.5, use {'gamma': 0.5}. To perform various gamma stretches on a three-band raster, use {'gamma': [0.5, 2, 1.5]}.

  • rft—A path to a raster function template (.rft.xml) where the stretch is defined by a raster function chain; for example, {'rft': r"C:\StretchFunctions\Remap_and_Stretch.rft.xml"}.

Dictionary
colormap

Defines the colors to use for rendering. If a rendering rule is not specified, a color map must be specified.

The parameter must use one of the following formats:

  • The name of a color map or color scheme that is supported in ArcGIS Pro; for example, colormap="Red to Green". For a full list of supported color schemes, download the ArcGIS_Pro_ColorSchemes.pdf PDF document.
  • A list of hex color codes, named colors, or both. There are 16 supported named colors:
    • aqua
    • black
    • blue
    • fuchsia
    • gray
    • green
    • lime
    • maroon
    • navy
    • olive
    • purple
    • red
    • silver
    • teal
    • white
    • yellow

    For example, ["#B0C4DE", "blue", "navy"].

  • A dictionary with the following key value pairs:
    • "values": [<pixel_value1>, <pixel_value2>, ... ]
    • "colors": ["<color1>", "<color2", ... ]
    • "labels": ["<label1>", "<label2>", ... ]

    For example, {"values": [11, 21, 30], "colors": ["#B0C4DE", "green", "gray"], "labels": ["water", "vegetation", "urban"]}

String
返回值
数据类型说明
Raster

输出已渲染栅格对象。

代码示例

Render 示例 1

使用线性拉伸和 NDVI 配色方案渲染单波段 NDVI 栅格。

import arcpy

# Set input raster
in_Raster = arcpy.Raster(r"C:\Data\NDVI_Raster.tif")

# Render the raster with a linear stretch and the NDVI color scheme
rendered_raster = arcpy.Render(inRaster, rendering_rule=
	{'min': 0, 'max': 0.8}, colormap='NDVI')
rendered_raster
Render 示例 2

使用已应用的拉伸以及每个波段的 Gamma 拉伸来渲染多波段 Landsat 7 伪彩色影像。

import arcpy

# Set input raster
in_Raster = arcpy.Raster(r"C:\Data\Landsat7.tif")

# Render the Landsat 7 image in false color composite
# Include a linear standard deviation stretch, and a gamma stretch for each band
rendered_raster = arcpy.Render(inRaster, rendering_rule=
	{'bands': [4,3,2], 'numberOfStandardDeviations': 2, 'gamma': [1,1.7,1.2]})
rendered_raster
Render 示例 3

使用自定义色彩映射表来渲染分类土地覆被栅格。

import arcpy

# Set input raster
in_Raster = arcpy.Raster(r"C:\Data\Landcover.tif")

# Render the landcover dataset with a custom color map
rendered_raster = arcpy.Render(inRaster, colormap=
	{"values": [11,21,31], "colors": ["#486DA2",  "gray",  "green"],
	"labels":["water", "urban", "forest"]})

rendered_raster
Render 示例 4

使用栅格函数模板和色彩映射表来渲染多维栅格。

import arcpy

# Set input multidimensional raster
in_Raster = arcpy.Raster(r"C:\Data\Landsat8_Time_Series.crf", True)

# Render each slice in the imagery time series data with a stretched 
# Normalized Difference Water Index described in a raster function template
rendered_raster = arcpy.Render(inRaster, rendering_rule=
	{'rft': r"C:\Data\NDWI.rft.xml"}, colormap="Red to Green")

rendered_raster