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.

  • 1
    javascript loops are not recommended but not forbidden Jul 17, 2017 at 15:25

3 Answers 3


One option is to use the projection of an image to define a grid over a region of interest. The grid cells will match the dimensions of the pixels in the image. The key function is coveringGrid():

var grid = polyFeature.geometry().coveringGrid(proj)

If you want a grid of points (instead of polygons), use Image.sample():

var pointGrid = image.sample({
  region: polyFeature.geometry(),
  projection: proj, // make sure to use the projection from the correct band
  geometries: true // if you want points

example code


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.


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...)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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