geetools.Geometry.GeometryAccessor.keepType#

geetools.Geometry.GeometryAccessor.keepType(type)#

Only keep the geometries of the given type from a GeometryCollection.

Parameters:

type (str) – The type of geometries to keep. Can be one of: Point, LineString, LineRing Polygon.

Returns:

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)
geom = geometryCol.geetools.keepType('LineString')
print(geom.getInfo())

Return type:

ee.Geometry