Foreach

Image Analyst ライセンスで利用できます。

Spatial Analyst のライセンスで利用可能。

サマリー

Creates a raster object by applying a raster function or a customized function template to every slice in the input multidimensional raster.

説明

Use the Foreach function to apply a raster function to every slice in a multidimensional raster dataset. To apply a raster function to a single slice, use the Subset function before using Foreach.

This function creates a raster object that contains the variables and dimensions of the input multidimensional raster, processed using a 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.

構文

Foreach (in_raster, raster_function, {raster_function_arguments})
パラメーター説明データ タイプ
in_raster

The input multidimensional raster dataset.

Raster
raster_function

The name of a raster function or the path to a custom raster function (.rft.xml file) to apply to every slice in the input multidimensional raster.

String
raster_function_arguments

The parameters and values associated with the raster function or function chain. If not specified, default values will be used.

For example, the Tasseled Cap raster function does not require any arguments; the input is a single raster, so there is no need to specify arguments.

The Arithmetic raster function, however, requires 5 input parameters: Raster, Raster2, Operation, Cellsize Type and Extent Type. To use Arithmetic with the Apply function, Raster and Raster2 are defined in the in_raster parameter, and the remaining parameters have default values, so if nothing is specified for those parameters, the default values will be used.

For information about the function arguments for each raster function, see Raster function objects.

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

The output multidimensional raster.

コードのサンプル

Foreach example

Calculate NDVI for each slice in a time series of Landsat 7 scenes.

import arcpy
from arcpy.ia import *

arcpy.CheckOutExtension("ImageAnalyst")

# Create multidimensional raster object from 
# Landsat7 time series data in a mosaic dataset
in_raster = Raster('C:\\test.gdb\\Landsat7', True) 

# Calculate NDVI for each scene in the time series
out_NDVI_raster = Foreach(
	in_raster, "NDVI", {'VisibleBandID':3,'InfraredBandID':4})