Earth Engine でのベクターからラスターへの変換は、featureCollection.reduceToImage()
メソッドによって処理されます。このメソッドは、各特徴の下のピクセルに指定されたプロパティの値を割り当てます。この例では、郡のデータを使用して、各郡の土地面積を表す画像を作成します。
コードエディタ(JavaScript)
// Load a collection of US counties. var counties = ee.FeatureCollection('TIGER/2018/Counties'); // Make an image out of the land area attribute. var landAreaImg = counties .filter(ee.Filter.notNull(['ALAND'])) .reduceToImage({ properties: ['ALAND'], reducer: ee.Reducer.first() }); // Display the county land area image. Map.setCenter(-99.976, 40.38, 5); Map.addLayer(landAreaImg, { min: 3e8, max: 1.5e10, palette: ['FCFDBF', 'FDAE78', 'EE605E', 'B63679', '711F81', '2C105C'] });
import ee import geemap.core as geemap
Colab(Python)
# Load a collection of US counties. counties = ee.FeatureCollection('TIGER/2018/Counties') # Make an image out of the land area attribute. land_area_img = counties.filter(ee.Filter.notNull(['ALAND'])).reduceToImage( properties=['ALAND'], reducer=ee.Reducer.first() ) # Display the county land area image. m = geemap.Map() m.set_center(-99.976, 40.38, 5) m.add_layer( land_area_img, { 'min': 3e8, 'max': 1.5e10, 'palette': ['FCFDBF', 'FDAE78', 'EE605E', 'B63679', '711F81', '2C105C'], }, ) m
重複する特徴のプロパティを集約する方法を指定するリデューサーを指定します。上記の例では重複がないため、ee.Reducer.first()
で十分です。この例のように、データを事前にフィルタして、画像に変換できない null を除外します。出力は図 1 のようになります。色のグラデーションが郡の面積にマッピングされています。Earth Engine のすべての画像出力レジューサーと同様に、スケールは出力によって動的に設定されます。この場合、スケールは Code Editor のズームレベルに対応します。

FeatureCollection
の「ALAND」(土地面積)プロパティを使用する reduceToImage()
の結果。