Colormap

概要

Transforms the pixel values to display the raster data as either a grayscale or an RGB color image based on a color scheme or specific colors in a color map file.

ディスカッション

For more information about how this function works, see the Colormap raster function.

The referenced raster dataset for the raster object is temporary. To make it permanent, you can call the raster object's save method.

構文

Colormap (raster, {Colormap}, {Color Ramp})
パラメーター説明データ タイプ
raster

The input raster.

Raster
Colormap

The following default color maps are available:

  • NoneNo color map. This is the default.
  • ElevationA color map that gradually changes from cyan to purple to black.
  • GrayA color map that gradually changes from black to white.
  • NDVIA color map to visualize vegetation. Values near zero are blue. Low values are brown. Then the colors gradually change from red, to orange, to yellow, to green, and to black as the vegetation index goes from low to high.
  • NDVI2A color map to visualize vegetation. Low values range from white to green. Then the colors range from gray, to purple, to violet, to dark blue, and to black as the vegetation index goes from low to high.
  • NDVI3A color map to visualize vegetation. Values near zero are blue. Then the colors gradually change from red, to orange, and to green as the vegetation index goes from low to high.
  • RandomA random color map.

(デフォルト値は次のとおりです None)

String
Color Ramp

Choose a pre-existing color ramp or create your own color scheme.

Can be a string specifying color ramp name such as Black To White, Yellow To Red, Slope, or other color ramp names supported in ArcGIS Pro

For more information about color ramp objects, see Color ramp objects.

(デフォルト値は次のとおりです None)

String
戻り値
データ タイプ説明
Raster

The output raster.

コードのサンプル

HeatIndex example 1

This example transforms the pixel values to display the raster data using specific colors.

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

# Set the local variables
raster = "C:/arcpyExamples/data/land_cover.tif"
# pixels with value = 1 will be red, pixels with value = 2 will be green, pixels
# with value = 3 will be blue 
customized_colormap = {"values": [1, 2, 3], "colors": ['red','green','blue']}
#or customized_colormap = [[1, 255, 0, 0], [2, 0, 255, 0], [3, 0, 0, 255]]
# it is same with the one above

# Execute Colormap function
out_land_cover_with_colormap = Colormap(raster, colormap = customized_colormap)

# Display in notebook
out_land_cover_with_colormap

関連トピック