I am relatively new to Earth Engine and am trying to understand GeometryCollection elements. I have seen this post, but otherwise haven't found much additional information. Coming from desktop GIS software, the notion of a single Feature with multiple geometric types is unusual. A couple of related questions:
(1) Conceptually: For a given Feature whose geometries are defined by a GeometryCollection, is it possible to remove portions of a GeometryCollection, or does that violate internal topology? For instance, if a single Feature is composed of LineString and Polygon types, does removing the LineString components somehow invalidate the Polygon types, since they are inherently bound together?
(2) Practically: The following example returns a FeatureCollection whose Feature geometries are either Polygon, MultiPolygon, or GeometryCollection. GeometryCollection geometries are composed of LineString and Polygon geometries. If it is possible to remove portions of GeometryCollections per (1) above, how would this be accomplished? The goal is to reduce the parent FeatureCollection into a single geometry type (or set of geometry types) that can be exported to shapefile (it does not appear that Earth Engine has built-in functionality to clean/separate incompatible GeometryCollection elements during export).
(3) There are plenty of operations that could be performed on mixed geometries, and for enormous datasets there may be some non-trivial space/cost reduction by using LineStrings instead of Polygons with near-zero width. However, if there is additional rationale for permitting mixed geometries, I would love to hear it.
// Area of interest
var aoi = ee.Geometry.Rectangle([-82.4685, 23.5529, -75.5471, 27.8867])
// Load and filter Earth Engine asset
var polys = ee.FeatureCollection("FAO/GAUL/2015/level2").filterBounds(aoi)
// Store Feature geometry type as a Feature-level property for filtering
polys = polys.map(function(f) {
return f.set('geo_type', f.geometry().type())
})
// View full collection
print(polys)
// Isolate and view GeometreyCollection elements
var nonPoly = polys.filter(ee.Filter.eq('geo_type', 'GeometryCollection'))
print(nonPoly)
// Visualize as needed
// Map.setCenter(-78.6, 25)
// Map.addLayer(nonPoly)
// Convert GeometryCollection elements into Polygon or MultiPolygon elements
// ????
How to filter through geometry of feature collection instead of properties?