Contents
How to calculate statistics in Google Earth Engine?
As you learned in the Earth Engine API tutorial, the key method for calculating statistics in an image region is reduceRegion (). ( Learn more about reducing image regions .) For example, suppose we want to calculate the number of pixels estimated to represent forest loss during the study period. For that purpose, consider the following code:
How to calculate forest loss in Google Earth Engine?
In this section, we’ll compare the total amount of forest loss that happened within the Congo Republic in the year 2012 to the amount of forest loss that happened within the country’s protected areas at the same time. As you learned in the Earth Engine API tutorial, the key method for calculating statistics in an image region is reduceRegion ().
How do you calculate area in Earth Engine?
To help compute areas, Earth Engine has the ee.Image.pixelArea () method which generates an image in which the value of each pixel is the pixel’s area in square meters. Multiplying the loss image with this area image and then summing over the result gives us a measure of area:
How is the scale determined in Earth Engine?
In general, specifying the scale is sufficient and results in more readable code. Earth Engine determines which pixels to input to the reducer by first rasterizing the region. If a scale is specified without a CRS, the region is rasterized in the image’s native projection scaled to the specified resolution.
How to set the scale in Google Earth?
There are two ways to set the scale: by specifying the scale parameter, or by specifying a CRS and CRS transform. (See the glossary for more information about CRS’s and CRS transforms).
Why is it important to convert pixels to area?
This conversion is important because we don’t necessarily know the size of the pixels input to reduceRegion (). To help compute areas, Earth Engine has the ee.Image.pixelArea () method which generates an image in which the value of each pixel is the pixel’s area in square meters.
How to get percentiles from an image in Google Earth?
Suppose I have a 1-band image that represents a species’ predicted density and distribution. I’d like to be able to spatially define regions based on density. For instance I’d like to extract pixels that represent the top 10% of of the population. That is, identify the largest valued pixels that when summed are 10% of the total sum of all pixels.
How to reduce a region in Google Earth?
The region over which to reduce is shown in white. Note that in this example the reduction is specified by providing the reducer ( ee.Reducer.mean () ), the geometry ( region.geometry () ), the scale (30 meters) and maxPixels for the maximum number of pixels to input to the reducer. A scale should always be specified in reduceRegion () calls.