AI-generated Key Takeaways
-
FeatureCollection groups related features and can contain other collections for operations like filtering and sorting.
-
A FeatureCollection can be created from a list of features with varying geometry types and properties.
-
Individual geometries or table datasets from the Earth Engine Data Catalog can also be turned into a FeatureCollection.
-
The
ee.FeatureCollection.randomPointsmethod generates a FeatureCollection of random points within a defined region.
Groups of related features can be combined into a FeatureCollection
, to
enable additional operations on the entire set such as filtering, sorting and rendering.
Besides just simple features (geometry + properties), feature collections can also contain
other collections.
The FeatureCollection
constructor
One way to create a FeatureCollection
is to provide the constructor with
a list of features. The features don't need to have the same geometry type or the same
properties. For example:
Code Editor (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 )
Individual geometries can also be turned into a FeatureCollection
of
just one Feature
:
Code Editor (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 )
Table Datasets
Earth Engine hosts a variety of table datasets. To load a table dataset, provide the
table ID to the FeatureCollection
constructor. For example, to load
RESOLVE Ecoregions data:
Code Editor (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 )
Note that as with image datasets, you can search for table datasets in the Earth Engine Data Catalog .
Random Samples
To get a collection of random points in a specified region, you can use:
Code Editor (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 )

