PATTERNS
zonal operations
Zonal operations analyze pixel values in one layer based zones (regions) defined by another layer. In Earth Engine, the zones are generally defined by features in a feature collection.
more soon
zonal area
These methods use the zones defined by the geometry of a feature collection to compute the area of each class in a nominal or boolean layer.
area of classes
This method returns a dictionary that reports the total area (in square meters) of each class (integer value) in the input raster.
var area_of_classes = geo.iZonal.areaClasses(image, scale, region, "band_name");
print(
"Area (square meters)",
area_of_classes
);
The table below describes the arguments.
ARGUMENT | DESCRIPTION |
---|---|
image | The boolean or nominal (class) image to compute the area for each unique pixel value. |
scale | The pixel scale for analysis to troubleshoot TIME OUT errors. It can be helpful to first run at a coarse resolution and then increase resolution (make number smaller) as appropriate. |
region | Feature collection with one or more features that define the area of analysis or study region. |
“band_name” | The band name in the image with the integer values that identify the classes to compute the area of. |
area of classes as percent of region
This method returns a dictionary that reports the total area of each class (integer value) in the input raster as a percent of the region. It takes the output from .areaClasses()
(above) as the input and returns a dictionary.
var class_percent_of_region = geo.iZonal.classPercentRegion(area_of_classes);
print(
"Area (percent of region)",
class_percent_of_region
)
;
complete pattern
Here is the complete pattern for calculating the area of raster classes and their percent area of a region.
var area_of_classes = geo.iZonal.areaClasses(image, scale, region, "band_name");
print(
"Area (square meters)",
area_of_classes
);
var class_percent_of_region = geo.iZonal.classPercentRegion(area_of_classes);
print(
"Area (percent of region)",
class_percent_of_region
)
;
zonal statistics
This method calculates a statistic of image values within a zone of analysis defined by one or more features in a feature collection. The output of the method is a feature collection with a new column that contains the statistic.
var fc_zonal_stat = geo.iZonal.zonalStats(dough, cutter, "statistic", scale);
The method takes four arguments that are defined in the table below.
ARGUMENTS | DESCRIPTION |
---|---|
dough | The image with pixel values to be analyzed. |
cutter | The feature collection with one or more features that define the zones of analysis. |
“statistic” | The statistic to calculate within each zone of analysis. Must be a string from these options: “sum”, “max”, “min”, “mean”, “count”, “variety” (“count” reports the number of pixels, while “variety” reports the number of unique pixel values). |
scale | The scale of analysis. When you encounter time out errors, you can try to resolve by changing the scale of analysis. If you do not encounter time out errors, you can leave this argument blank. |
This work is licensed under CC BY-NC-SA 4.0