گروههایی از ویژگیهای مرتبط را میتوان در یک FeatureCollection
ترکیب کرد تا عملیاتهای اضافی را در کل مجموعه فعال کند، مانند فیلتر کردن، مرتبسازی و رندر کردن. علاوه بر ویژگیهای ساده (هندسه + ویژگیها)، مجموعههای ویژگی میتوانند مجموعههای دیگری نیز داشته باشند.
سازنده FeatureCollection
یکی از راه های ایجاد FeatureCollection
این است که لیستی از ویژگی ها را در اختیار سازنده قرار دهید. نیازی نیست که ویژگی ها دارای یک نوع هندسه یا ویژگی های یکسان باشند. به عنوان مثال:
ویرایشگر کد (جاوا اسکریپت)
// 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
کولب (پایتون)
# 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)
هندسههای مجزا را میتوان به FeatureCollection
تنها یک Feature
تبدیل کرد:
ویرایشگر کد (جاوا اسکریپت)
// 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
کولب (پایتون)
# 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 میزبان انواع مجموعه داده های جدول است. برای بارگذاری مجموعه داده جدول، شناسه جدول را به سازنده FeatureCollection
ارائه دهید. به عنوان مثال، برای بارگیری داده های RESOLVE Ecoregions:
ویرایشگر کد (جاوا اسکریپت)
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
کولب (پایتون)
fc = ee.FeatureCollection('RESOLVE/ECOREGIONS/2017') m = geemap.Map() m.set_center(12.17, 20.96, 3) m.add_layer(fc, {}, 'ecoregions') display(m)
توجه داشته باشید که مانند مجموعه داده های تصویری، می توانید مجموعه داده های جدول را در کاتالوگ داده موتور زمین جستجو کنید.
نمونه های تصادفی
برای به دست آوردن مجموعه ای از نقاط تصادفی در یک منطقه مشخص، می توانید از موارد زیر استفاده کنید:
ویرایشگر کد (جاوا اسکریپت)
// 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
کولب (پایتون)
# 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)