ee.FeatureCollection

אפשר ליצור FeatureCollection מהארגומנטים הבאים:

  – מחרוזת: נניח שזה השם של אוסף.

  – גיאומטריה אחת.

  – תכונה בודדת.

  – רשימת תכונות.

  – GeoJSON FeatureCollection

  – אובייקט מחושב: מתפרש מחדש כאוסף.

שימושהחזרות
ee.FeatureCollection(args, column)FeatureCollection
ארגומנטסוגפרטים
args‫ComputedObject|Feature|FeatureCollection|Geometry|List<Object>|Number|Stringהארגומנטים של ה-constructor.
columnמחרוזת, אופציונליהשם של עמודת הגיאומטריה שבה רוצים להשתמש. האפשרות הזו שימושית רק כשעובדים עם אוסף בעל שם.

דוגמאות

עורך הקוד (JavaScript)

// FeatureCollection from a string (collection name). Note that this only works
// with client-side strings, it won't accept computed, server-side strings.
var collectionName = 'WRI/GPPD/power_plants';
var collectionNameFc = ee.FeatureCollection(collectionName);
print('FeatureCollection from a string', collectionNameFc.limit(5));

// FeatureCollection from a single geometry.
var singleGeometry = ee.Geometry.Point(-62.54, -27.32);
var singleGeometryFc = ee.FeatureCollection(singleGeometry);
print('FeatureCollection from a single geometry', singleGeometryFc);

// FeatureCollection from a single feature.
var singleFeature = ee.Feature(ee.Geometry.Point(-62.54, -27.32), {key: 'val'});
var singleFeatureFc = ee.FeatureCollection(singleFeature);
print('FeatureCollection from a single feature', singleFeatureFc);

// FeatureCollection from a list of features.
var listOfFeatures = [
  ee.Feature(ee.Geometry.Point(-62.54, -27.32), {key: 'val1'}),
  ee.Feature(ee.Geometry.Point(-69.18, -10.64), {key: 'val2'}),
  ee.Feature(ee.Geometry.Point(-45.98, -18.09), {key: 'val3'})
];
var listOfFeaturesFc = ee.FeatureCollection(listOfFeatures);
print('FeatureCollection from a list of features', listOfFeaturesFc);

// FeatureCollection from GeoJSON.
var geojson = {
  "type": "FeatureCollection",
  "columns": {
    "key": "String",
    "system:index": "String"
  },
  "features": [
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [
          -62.54,
          -27.32
        ]
      },
      "id": "0",
      "properties": {
        "key": "val1"
      }
    }
  ]
};
var geojsonFc = ee.FeatureCollection(geojson);
print('FeatureCollection from GeoJSON', geojsonFc);

הגדרת Python

מידע על Python API ועל שימוש ב-geemap לפיתוח אינטראקטיבי מופיע בדף Python Environment.

import ee
import geemap.core as geemap

Colab (Python)

# FeatureCollection from a string (collection name). Note that this only works
# with client-side strings, it won't accept computed, server-side strings.
collection_name = 'WRI/GPPD/power_plants'
collection_name_fc = ee.FeatureCollection(collection_name)
print('FeatureCollection from a string:', collection_name_fc.limit(5).getInfo())

# FeatureCollection from a single geometry.
single_geometry = ee.Geometry.Point(-62.54, -27.32)
single_geometry_fc = ee.FeatureCollection(single_geometry)
print('FeatureCollection from a single geometry:', single_geometry_fc.getInfo())

# FeatureCollection from a single feature.
single_feature = ee.Feature(ee.Geometry.Point(-62.54, -27.32), {'key': 'val'})
single_feature_fc = ee.FeatureCollection(single_feature)
print('FeatureCollection from a single feature:', single_feature_fc.getInfo())

# FeatureCollection from a list of features.
list_of_features = [
    ee.Feature(ee.Geometry.Point(-62.54, -27.32), {'key': 'val1'}),
    ee.Feature(ee.Geometry.Point(-69.18, -10.64), {'key': 'val2'}),
    ee.Feature(ee.Geometry.Point(-45.98, -18.09), {'key': 'val3'})
]
list_of_features_fc = ee.FeatureCollection(list_of_features)
print('FeatureCollection from a list of features:',
      list_of_features_fc.getInfo())

# FeatureCollection from GeoJSON.
geojson = {
    'type': 'FeatureCollection',
    'columns': {
        'key': 'String',
        'system:index': 'String'
        },
    'features': [
        {
            'type': 'Feature',
            'geometry': {
                'type': 'Point',
                'coordinates': [
                    -62.54,
                    -27.32
                    ]
                },
            'id': '0',
            'properties': {
                'key': 'val1'
                }
            }
        ]
    }
geojson_fc = ee.FeatureCollection(geojson)
print('FeatureCollection from GeoJSON:', geojson_fc.getInfo())