Let's say that I want to chart daily mean sea surface temperatures per X by X degree cell over time, within some larger patch of the ocean. As per these instructions, this is easily done in GEE using ui.Chart.image.seriesByRegion(). That is, provided you have already defined a FeatureCollection of all the individual polygon regions (i.e. X by X degree cells) first.

Defining this collection of gridded cells is where I am getting stuck. Is there a smart way to automate this step? Perhaps one can even construct the cells from the properties of an imported image collection, e.g. one of the gridded NOAA datasets?

Alternatively, I could draw each of the cell polygons by hand, but this is obviously inefficient and haphazard. I could also write a javascript loop, but loops are supposedly best avoided in GEE as I understand it.

FWIW, in R I would use sp::makegrid() or do something like this.

  • javascript loops are not recommended but not forbidden – Rodrigo E. Principe Jul 17 '17 at 15:25

I'd forgotten about this question, but (as intimated by @Rodrigo above) it turned out that a regular for-loop was, indeed, the easiest solution.

MWE here: https://code.earthengine.google.com/cf1d2e6e8c6375d33c48f0a121293bb0

(Though, I'm still surprised GEE doesn't have a built-in "makegrid" function...)

| improve this answer | |

1000 meter grid of points over Puerto Rico.

var x = ee.List.sequence(-7569586.3359, -7254524.5697, 1000)
var y = ee.List.sequence(2017836.3574, 2104140.5776, 1000)
var features = ee.FeatureCollection(
    var feat = ee.FeatureCollection(
        return ee.Feature(
          ee.Geometry.Point([xcor, ycor], ee.Projection("EPSG:3857"))
    return feat


Source by thisearthsite at mygeoblog.com, revised by me.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.