PATTERNS
vector operations
Vector operations work with tables of geometries and often attributes.
transform geometries
These methods create new geometries based on the input geometries of feature collections.
More to come.
bounding box
var fc_bounds = geo.fcGeometry.boundingBox(fc);
Map.addLayer(fc_bounds, {color: 'cyan'}, "Bounding box", false);
centroid
var fc_centroid = geo.fcGeometry.centroidPoint(fc);
Map.addLayer(fc_centroid, {color: 'yellow'}, "Centroid point", false);
convex hull
var fc_convex_hull = geo.fcGeometry.convexHullPolygon(fc);
Map.addLayer(fc_convex_hull, {color: 'magenta'}, "Convex hull", false);
multipart vs. single part geometries
These methods change the form of the geometries liked to rows in a table. The picture below illustrates several concepts. The leftmost frame (A) shows a table with a singlepart geometry; a single polygon linked to each row in the table. The center frame (B) shows a table linked to multipart geometry (multipart geometry can link two or more polygons to a single row of attributes). The rightmost frame (C) shows another table with multipart geometries; four polygons associated with one row.
Operations are shown laterally. Moving from A to B is a dissolve operation (singlepart → multipart), while moving from B to A is an explode operation (multipart → singlepart). Note the asymmetry between moves on the right side. From B to C is another dissolve, but from C to B is not possible.
dissolve by attribute
This will dissolve a feature collection into multipart features that share a common attribute.
// -------------------------------------------------------------
// Dissolve by attribute
// -------------------------------------------------------------
var output_dissolve = geo.fcGeometry.dissolveByAttribute(fc, "property");
print("DISSOLVE", fc.first(), output_dissolve.first());
Using the illustration at the top of this section, the snippet below will transform A into B.
var B = geo.fcGeometry.dissolveByAttribute(A, "GRADE");
Please note that the property name is literal (and case sensitive), so when working with HOLC data you would need to specify “holc_grade” to transform A to B and “city” to transform B to C.
vector overlay
Vector overlay operations compare locations between two vector layers. In Earth Engine, the vector layers are generally features in a feature collection.
more soon
clip by region
geo.fcOverlay.clipByRegion()
is a knife method that takes two arguments.
ARGUMENT | DESCRIPTION |
---|---|
fc_dough | A vector dataset (feature collection) with features that you want to cut. |
fc_cutter | A vector dataset (feature collection) with features that you want to use as the knife to cut the dough. |
The output is a feature collection that retains that attributes but alters the geometry of the dough.
var fc_clip = geo.fcOverlay.clipByRegion(fc_dough, fc_cutter);
This work is licensed under CC BY-NC-SA 4.0