関連する特徴のグループを FeatureCollection
に結合して、フィルタリング、並べ替え、レンダリングなどのセット全体に対する追加のオペレーションを有効にできます。特徴コレクションには、単純な特徴(ジオメトリとプロパティ)以外に、他のコレクションを含めることもできます。
FeatureCollection
コンストラクタ
FeatureCollection
を作成する方法の 1 つは、コンストラクタに対象物のリストを提供することです。特徴が同じジオメトリ タイプや同じプロパティを持つ必要はありません。次に例を示します。
コードエディタ(JavaScript)
// Make a list of Features. var features = [ ee.Feature(ee.Geometry.Rectangle(30.01, 59.80, 30.59, 60.15), {name: 'Voronoi'}), ee.Feature(ee.Geometry.Point(-73.96, 40.781), {name: 'Thiessen'}), ee.Feature(ee.Geometry.Point(6.4806, 50.8012), {name: 'Dirichlet'}) ]; // Create a FeatureCollection from the list and print it. var fromList = ee.FeatureCollection(features); print(fromList);
import ee import geemap.core as geemap
Colab(Python)
# Make a list of Features. features = [ ee.Feature( ee.Geometry.Rectangle(30.01, 59.80, 30.59, 60.15), {'name': 'Voronoi'} ), ee.Feature(ee.Geometry.Point(-73.96, 40.781), {'name': 'Thiessen'}), ee.Feature(ee.Geometry.Point(6.4806, 50.8012), {'name': 'Dirichlet'}), ] # Create a FeatureCollection from the list and print it. from_list = ee.FeatureCollection(features) display(from_list)
個々のジオメトリを 1 つの Feature
の FeatureCollection
に変換することもできます。
コードエディタ(JavaScript)
// Create a FeatureCollection from a single geometry and print it. var fromGeom = ee.FeatureCollection(ee.Geometry.Point(16.37, 48.225)); print(fromGeom);
import ee import geemap.core as geemap
Colab(Python)
# Create a FeatureCollection from a single geometry and print it. from_geom = ee.FeatureCollection(ee.Geometry.Point(16.37, 48.225)) display(from_geom)
テーブル データセット
Earth Engine には、さまざまなテーブル データセットがホストされています。テーブル データセットを読み込むには、テーブル ID を FeatureCollection
コンストラクタに指定します。たとえば、RESOLVE エコリージョン データを読み込むには:
コードエディタ(JavaScript)
var fc = ee.FeatureCollection('RESOLVE/ECOREGIONS/2017'); Map.setCenter(12.17, 20.96, 3); Map.addLayer(fc, {}, 'ecoregions');
import ee import geemap.core as geemap
Colab(Python)
fc = ee.FeatureCollection('RESOLVE/ECOREGIONS/2017') m = geemap.Map() m.set_center(12.17, 20.96, 3) m.add_layer(fc, {}, 'ecoregions') display(m)
画像データセットと同様に、テーブル データセットは Earth Engine Data Catalog で検索できます。
ランダム サンプリング
指定したリージョン内のランダムなポイントのコレクションを取得するには、次のコマンドを使用します。
コードエディタ(JavaScript)
// Define an arbitrary region in which to compute random points. var region = ee.Geometry.Rectangle(-119.224, 34.669, -99.536, 50.064); // Create 1000 random points in the region. var randomPoints = ee.FeatureCollection.randomPoints(region); // Display the points. Map.centerObject(randomPoints); Map.addLayer(randomPoints, {}, 'random points');
import ee import geemap.core as geemap
Colab(Python)
# Define an arbitrary region in which to compute random points. region = ee.Geometry.Rectangle(-119.224, 34.669, -99.536, 50.064) # Create 1000 random points in the region. random_points = ee.FeatureCollection.randomPoints(region) # Display the points. m = geemap.Map() m.center_object(random_points) m.add_layer(random_points, {}, 'random points') display(m)