お知らせ :
2025 年 4 月 15 日 より前に Earth Engine の使用を登録したすべての非商用プロジェクトは、アクセスを維持するために
非商用目的での利用資格を確認 する必要があります。2025 年 9 月 26 日までに確認が完了していない場合、アクセスが保留されることがあります。
フィードバックを送信
ee.Image.sampleRegions
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
1 つ以上のリージョンと交差する画像(特定のスケール)の各ピクセルを Feature に変換し、FeatureCollection として返します。各出力フィーチャーには、入力画像のバンドごとに 1 つのプロパティと、入力フィーチャーからコピーされた指定のプロパティが含まれます。
ジオメトリはピクセルの中心にスナップされます。
用途 戻り値 Image. sampleRegions (collection, properties , scale , projection , tileScale , geometries )
FeatureCollection
引数 タイプ 詳細 これ: image
画像 サンプリングする画像。 collection
FeatureCollection サンプリングするリージョン。 properties
リスト、デフォルト: null 各入力特徴からコピーするプロパティのリスト。デフォルトはすべてのシステム以外のプロパティです。 scale
浮動小数点数、デフォルト: null サンプリングする投影のメートル単位の名義尺度。指定しない場合、イメージの最初のバンドのスケールが使用されます。 projection
Projection、デフォルト: null サンプリングする投影。指定しない場合、イメージの最初のバンドの投影が使用されます。スケールに加えて指定された場合、指定されたスケールに再スケーリングされます。 tileScale
浮動小数点数、デフォルト: 1 集計タイルのサイズを縮小するために使用されるスケーリング ファクタ。tileScale を大きくすると(例: 2 または 4)を使用すると、デフォルトでメモリ不足になる計算が可能になる場合があります。 geometries
ブール値。デフォルト値は false です。 true の場合、結果にはサンプリングされたピクセルごとにポイント ジオメトリが含まれます。それ以外の場合、ジオメトリは省略されます(メモリが節約されます)。
例
コードエディタ(JavaScript)
// A Sentinel-2 surface reflectance image.
var img = ee . Image ( 'COPERNICUS/S2_SR/20210109T185751_20210109T185931_T10SEG' );
Map . setCenter ( - 122.503881 , 37.765588 , 18 );
Map . addLayer ( img , { bands : [ 'B11' , 'B8' , 'B3' ], min : 100 , max : 4500 }, 'img' );
// A feature collection with two polygon regions each intersecting 36
// pixels at 10 m scale.
var fcPolygon = ee . FeatureCollection ([
ee . Feature ( ee . Geometry . Rectangle (
- 122.50620929 , 37.76502806 , - 122.50552264 , 37.76556663 ), { id : 0 }),
ee . Feature ( ee . Geometry . Rectangle (
- 122.50530270 , 37.76565568 , - 122.50460533 , 37.76619425 ), { id : 1 })
]);
Map . addLayer ( fcPolygon , { color : 'yellow' }, 'fcPolygon' );
var fcPolygonSamp = img . sampleRegions ({
collection : fcPolygon ,
scale : 10 ,
geometries : true
});
// Note that 7 pixels are missing from the sample. If a pixel contains a masked
// band value it will be excluded from the sample. In this case, the TCI_B band
// is masked for each unsampled pixel.
print ( 'A feature per pixel (at given scale) in each region' , fcPolygonSamp );
Map . addLayer ( fcPolygonSamp , { color : 'purple' }, 'fcPolygonSamp' );
// A feature collection with two points intersecting two different pixels.
// This example is included to show the behavior for point geometries. In
// practice, if the feature collection is all points, ee.Image.reduceRegions
// should be used instead to save memory.
var fcPoint = ee . FeatureCollection ([
ee . Feature ( ee . Geometry . Point ([ - 122.50309256 , 37.76605006 ]), { id : 0 }),
ee . Feature ( ee . Geometry . Point ([ - 122.50344661 , 37.76560903 ]), { id : 1 })
]);
Map . addLayer ( fcPoint , { color : 'cyan' }, 'fcPoint' );
var fcPointSamp = img . sampleRegions ({
collection : fcPoint ,
scale : 10
});
print ( 'A feature per point' , fcPointSamp );
Python の設定
Python API とインタラクティブな開発での geemap
の使用については、
Python 環境 のページをご覧ください。
import ee
import geemap.core as geemap
Colab(Python)
# A Sentinel-2 surface reflectance image.
img = ee . Image ( 'COPERNICUS/S2_SR/20210109T185751_20210109T185931_T10SEG' )
m = geemap . Map ()
m . set_center ( - 122.503881 , 37.765588 , 18 )
m . add_layer (
img , { 'bands' : [ 'B11' , 'B8' , 'B3' ], 'min' : 100 , 'max' : 4500 }, 'img'
)
display ( m )
# A feature collection with two polygon regions each intersecting 36
# pixels at 10 m scale.
fc_polygon = ee . FeatureCollection ([
ee . Feature (
ee . Geometry . Rectangle (
- 122.50620929 , 37.76502806 , - 122.50552264 , 37.76556663
),
{ 'id' : 0 },
),
ee . Feature (
ee . Geometry . Rectangle (
- 122.50530270 , 37.76565568 , - 122.50460533 , 37.76619425
),
{ 'id' : 1 },
),
])
m . add_layer ( fc_polygon , { 'color' : 'yellow' }, 'fc_polygon' )
fc_polygon_samp = img . sampleRegions (
collection = fc_polygon , scale = 10 , geometries = True
)
# Note that 7 pixels are missing from the sample. If a pixel contains a masked
# band value it will be excluded from the sample. In this case, the TCI_B band
# is masked for each unsampled pixel.
display ( 'A feature per pixel (at given scale) in each region' , fc_polygon_samp )
m . add_layer ( fc_polygon_samp , { 'color' : 'purple' }, 'fc_polygon_samp' )
# A feature collection with two points intersecting two different pixels.
# This example is included to show the behavior for point geometries. In
# practice, if the feature collection is all points, ee.Image.reduceRegions
# should be used instead to save memory.
fc_point = ee . FeatureCollection ([
ee . Feature ( ee . Geometry . Point ([ - 122.50309256 , 37.76605006 ]), { 'id' : 0 }),
ee . Feature ( ee . Geometry . Point ([ - 122.50344661 , 37.76560903 ]), { 'id' : 1 }),
])
m . add_layer ( fc_point , { 'color' : 'cyan' }, 'fc_point' )
fc_point_samp = img . sampleRegions ( collection = fc_point , scale = 10 )
display ( 'A feature per point' , fc_point_samp )
フィードバックを送信
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンス により使用許諾されます。コードサンプルは Apache 2.0 ライセンス により使用許諾されます。詳しくは、Google Developers サイトのポリシー をご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-07-26 UTC。
ご意見をお聞かせください
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-07-26 UTC。"],[],["The `Image.sampleRegions` method converts image pixels intersecting specified regions into a `FeatureCollection`. Each output feature contains properties from the input image bands and any designated input feature properties. Geometries are snapped to pixel centers. The sampling scale and projection can be specified; otherwise, the image's first band defaults are used. Optionally, geometries of the sampled pixels can be included, and tile scaling can be used for memory management.\n"]]