geetools.FeatureCollection#
Toolbox for the ee.FeatureCollection class.
Classes#
Toolbox for the ee.FeatureCollection class. |
Package Contents#
- class geetools.FeatureCollection.FeatureCollectionAccessor(obj)[source]#
Toolbox for the ee.FeatureCollection class.
Initialize the FeatureCollection class.
- Parameters:
obj (ee.FeatureCollection)
- addId(name='id', start=1)[source]#
Add a unique numeric identifier, starting from parameter
start.- Returns:
The parsed collection with a new id property
- Parameters:
name (geetools.types.ee_str)
start (geetools.types.ee_int)
- Return type:
ee.FeatureCollection
Example
import ee import geetools ee.Initialize() fc = ee.FeatureCollection('FAO/GAUL/2015/level0') fc = fc.geetools.addId() print(fc.first().get('id').getInfo())
- mergeGeometries()[source]#
Merge the geometries the included features.
- Returns:
the dissolved geometry
- Return type:
ee.Geometry
Example
import ee import geetools ee.Initialize() fc = ee.FeatureCollection("FAO/GAUL/2015/level0") fc =fc.filter(ee.Filter.inList("ADM0_CODE", [122, 237, 85])) geom = fc.geetools.mergeGeometries() print(geom.getInfo())
- toImage(color=0, width='')[source]#
Paint the current FeatureCollection to an Image.
It’s simply a wrapper on Image.paint() method
- Parameters:
color (Union[geetools.types.ee_str, geetools.types.ee_int]) – The pixel value to paint into every band of the input image, either as a number which will be used for all features, or the name of a numeric property to take from each feature in the collection.
width (Union[geetools.types.ee_str, geetools.types.ee_int]) – Line width, either as a number which will be the line width for all geometries, or the name of a numeric property to take from each feature in the collection. If unspecified, the geometries will be filled instead of outlined.
- Return type:
ee.Image
- toPolygons()[source]#
Drop any geometry that is not a Polygon or a multipolygon.
This method is made to avoid errors when performing zonal statistics and/or other surfaces operations. These operations won’t work on geometries that are Lines or points. The methods remove these geometry types from GEometryCollections and rremove features that don’t have any polygon geometry
- Returns:
The parsed collection with only polygon/MultiPolygon geometries
- Return type:
ee.FeatureCollection
Example
import ee import geetools ee.Initialize() point0 = ee.Geometry.Point([0,0], proj="EPSG:4326") point1 = ee.Geometry.Point([0,1], proj="EPSG:4326") poly0 = point0.buffer(1, proj="EPSG:4326") poly1 = point1.buffer(1, proj="EPSG:4326").bounds(proj="EPSG:4326") line = ee.Geometry.LineString([point1, point0], proj="EPSG:4326") multiPoly = ee.Geometry.MultiPolygon([poly0, poly1], proj="EPSG:4326") geometryCol = ee.Algorithms.GeometryConstructors.MultiGeometry([multiPoly, poly0, poly1, point0, line], crs="EPSG:4326", geodesic=True, maxError=1) fc = ee.FeatureCollection([geometryCol]) fc = fc.geetools.toPolygons() print(fc.getInfo())