Earth Engine by Example

I’ve never had much use for hex maps — until now.

A 50km hex grid based on an Albers equal-area projection with a random color scheme. https://goo.gle/3tTUssJ

In a previous article, I demonstrated how to generate a random sample with buffering to guarantee that no two samples are closer than a given distance. Since then, a (now obvious) idea occurred to me that using a hex grid instead of a rectangular one would pack more samples into the same region while still observing the minimum distance requirement.

Here’s a ‘relatively simple’ way to generate a hex grid like the image above, starting from a rectangular pixelCoordinates image in a given projection. Each…


Earth Engine by Example

In the Earth Engine Code Editor Examples, there’s an example of doing circle finding by kernel convolution. This article will demonstrate another method for circle detection that has a little more flexibility called the Circle Hough Transform (CHT).

An example of Circle Hough Transform applied to an edge-detected image of center pivot irrigation farms in Southern Colorado. The colored dots represent detected circle centers. Cool colors (purple, aqua, green) indicate better fits, and warmer colors (red, orange, yellow) indicate weaker fits.

The usual recipe for CHT is:

  • Smooth the input with a Gaussian convolution
  • Perform edge detection with the Canny edge detector
  • Iterate over pixels in the image, drawing a circle of a given radius for each input pixel into an accumulator image.
  • Find the highest values in the accumulator; these will correspond to the center of any circles…


Earth Engine by Example

A common concern when doing land cover classifications is the risk of spatial autocorrelation in sampled data skewing the prediction results or accuracy assessment. One method that can help with this issue is ensuring the training and validation samples are sufficiently spaced using some form of buffering. This example will demonstrate one way to do that.

A brute-force method for generating a random sample with a buffer might be to take a large set of samples and filter those down to a smaller number by discarding close neighbors. However, picking which points to start from can…


Earth Engine by Example

A common problem people struggle to solve with Earth Engine is computing various kinds of runs, especially through time using an Image Collection. Calculating these kinds of values involves looking at a pixel’s temporal neighbors, and Earth Engine collections don’t readily support that. This example will show you how to solve these kinds of problems using Earth Engine Arrays.

Just in case you’ve never seen or used an Earth Engine Array, it’s a numeric type that can hold multiple values, arranged as a multidimensional (rectangular) array. …


Earth Engine by Example

Histogram matching is a quick and easy way to “calibrate” one image to match another. In mathematical terms, it’s the process of transforming one image so that the cumulative distribution function (CDF) of values in each band matches the CDF of bands in another image.

To illustrate what this looks like and how it works, I’m going to histogram-match a high-resolution (0.8m/pixel) SkySat image to the Landsat 8 calibrated surface reflectance images taken around the same time. Below is what it looks like with the SkySat image overlaid on top of the Landsat data, before the matching. …

Noel Gorelick

I’m a software engineer at Google and one of the founders of Google Earth Engine.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store