In Earth Engine, when exporting to drive the raster is shifted

alignmentexportgoogle-earth-engine-javascript-apilandsat 8usgs

The Problem:

Two identical Landsat scenes were downloaded from two different sources. USGS Earth Explorer and Google Earth Engine. Although both of the scenes are in the exact same coordinate system (EPSG:32638), their pixels do not align correctly. They are shifted 15 meters both horizontally and vertically as shown Below:

enter image description here
I believe that the USGS raster is the correct one, while GEE one has some issues when exporting it.

Data:

To generate the GEE raster please see the following GEE code:

var image = ee.Image('LANDSAT/LC08/C02/T1_L2/LC08_168037_20210918').select('SR_B2')
Map.centerObject(image,8);
Map.addLayer(image , null,'Band 2');

Export.image.toDrive({
    image: image,
    description: 'testImage',
    fileNamePrefix: 'testImage',
    scale: 30,
    // region: aoi,
    maxPixels: 1e10,
    crs:'EPSG:32638',
    folder: 'Image Production'
    })
  • USGS raster can be downloaded here
  • GEE raster can be downloaded here

Non-Working solutions:

My request:

  • To be able to export Landsat8 rasters perfectly aligned with their corresponding ones in USGS Earth explorer.
  • To be able to export Sentinel2 rasters perfectly aligned with their corresponding ones in Scihub.

Best Answer

If you additionally pass in the crs transform to the export call and remove the scale parameter everything should line up perfectly. You can access the transform like this: image.projection().getInfo().transform.

Then you can export like this:

Export.image.toDrive({
    image: image,
    description: 'testImage',
    fileNamePrefix: 'testImage',
    // region: aoi,
    maxPixels: 1e10,
    crs:'EPSG:32638',
    crsTransform: image.projection().getInfo().transform,
    folder: 'Image Production'
})
Related Question