Ashish SumanGeospatial data scientist · PhD scholar, JNU Get in touch

Nov 2026

Earth Engine: pass crsTransform, not scale, if you want one national grid

When every city is exported separately, a shared pixel grid keeps them aligned. In Earth Engine that grid survives only if you pass crsTransform and leave out scale.

A national analysis in Earth Engine is usually run in pieces: one export per city, per state or per tile. If each piece chooses its own pixel grid, two neighbouring pieces can sit half a pixel apart, and a pixel on the boundary is counted twice or not at all.

The remedy is one national grid: a single origin and pixel size that every export snaps to. For a 30 m grid on a projected coordinate system:

CRS_TRANSFORM = [30, 0, X_ORIGIN, 0, -30, Y_ORIGIN]   # xScale, xShear, xOffset, yShear, yScale, yOffset

ee.batch.Export.image.toDrive(
    image=img, region=region,
    crs=CRS_WKT, crsTransform=CRS_TRANSFORM,   # no scale=
)

The origin is the upper-left corner of a box larger than the whole country, snapped to a whole multiple of 30 m, and yScale is negative because rows run south.

The trap

If you pass both scale and crsTransform, Earth Engine uses scale and quietly drops the transform. Nothing fails, the export looks right, and the grid is lost. Pass crsTransform alone.

A second trap: year codes

If the image holds codes rather than measurements (a year of first detection, a class), any interpolation invents values that do not exist. Earth Engine’s default reprojection is nearest neighbour, which keeps codes intact; never call .resample() on a coded image.

All notes →