ポリゴンで抽出(Extract by Polygon) (Spatial Analyst)

サマリ

ポリゴンに基づいてラスタのセルを抽出します。

使用法

構文

ExtractByPolygon (in_raster, polygon, {extraction_area})
パラメータ説明データ タイプ
in_raster

セルを抽出する入力ラスタ。

Raster Layer
polygon
[point,...]

抽出する入力ラスタのエリアを定義するポリゴン。

それぞれのポリゴン パーツは、ポイント クラスによって定義される頂点のリストです。オプションで、ポリゴン クラスを使用して、ポリゴン パーツのリストを定義できます。

ポイントは、X、Y 座標の組として指定されます。オブジェクトの形式:

  • [[point(x1,y1), point(x2,y2),point(xn,yn),...point(x1,y1)], [point(x'1,y'1), point(x'2,y'2),point(x'n,y'n),...,point(x'1,y'1)]

ポリゴンを閉じるため、最後の座標は最初の座標と同じである必要がありますので、注意してください。

Point
extraction_area
(オプション)

入力ポリゴンの内部と外部のどちらのセルを抽出するかを識別します。

  • INSIDE 入力ポリゴンの内部のセルを選択し、出力ラスタに書き込むことを指定するキーワード。ポリゴンの外部にあるすべてのセルは、出力ラスタでは値が NoData になります。
  • OUTSIDE 入力ポリゴンの外部のセルを選択し、出力ラスタに書き込むことを指定するキーワード。ポリゴンの内部にあるすべてのセルは、出力ラスタでは値が NoData になります。
String

リターン

名前説明データ タイプ
out_raster

入力ラスタから抽出したセル値が格納される出力ラスタ。

Raster

コードのサンプル

ExtractByPolygon(ポリゴンで抽出)の例 1(Python ウィンドウ)

次の例では、定義されたポリゴン座標に基づいて、ラスタからセルを抽出しています。

import arcpy
from arcpy import env
from arcpy.sa import *
polyPoints = [arcpy.Point(743050, 4321275), arcpy.Point(743100, 4321200), 
             arcpy.Point(743500, 4322000),arcpy.Point(742900, 4321800)]
env.workspace = "C:/sapyexamples/data"
extPolygonOut = ExtractByPolygon("soil", polyPoints, "INSIDE")
extPolygonOut.save("c:/sapyexamples/output/extpoly")
ExtractByPolygon(ポリゴンで抽出)の例 2(スタンドアロン スクリプト)

次の例では、定義されたポリゴン座標に基づいて、ラスタからセルを抽出しています。

# Name: ExtractByPolgyon_Ex_02.py
# Description: Extracts the cells of a raster based on a polygon.
# 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 = "soil"
polyPoints = [arcpy.Point(743050, 4321275), arcpy.Point(743100, 4321200), 
             arcpy.Point(743500, 4322000),arcpy.Point(742900, 4321800)]

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

# Execute ExtractByPolygon
extPolygonOut = ExtractByPolygon(inRaster, polyPoints, "INSIDE")

# Save the output 
extPolygonOut.save("c:/sapyexamples/output/extpoly02")

環境

関連項目

ライセンス情報

ArcView: 必須 Spatial Analyst
ArcEditor: 必須 Spatial Analyst
ArcInfo: 必須 Spatial Analyst

7/10/2012