2

I've created an EE image object with a bunch of bands that lacks any projection information (per the GEE documentation: In particular, note that images produced by reducing an ImageCollection have no projection. This means that you should explicitly set the scale on any computations involving computed images output by an ImageCollection reduction.). I want to aggregate (that is, use a mean reducer in GEE lingo) my data to a standard, moderate resolution--say, 1km. But since .reduceResolution only accepts images that already have a projection, I find myself in the awkward position of having to force reproject to a smallish resolution, then use .reduceResolution(mean), then force reproject again to my desired size...all before having to set the scale again when I go to export the image.

Surely I am making this more complicated than it needs to be. Is there a way to set the export parameters such that it uses .reduceResolution(mean) when the data is exported?

Here's some simplified code to illustrate my problem:

    var AllData = LandsatComposite.addBands(Temp)
                                    .addBands(Elevation).toFloat()
                                    .reproject({crs: 'EPSG:32620', scale: 30})
                                    .reduceResolution({reducer: ee.Reducer.mean()})
                                    .reproject({crs: 'EPSG:32620', scale: 100});

Export.image.toDrive({
 image: AllData.select('B1', 'B2', 'B3', 'Temp', 'Elevation').updateMask(mask),
 description: "AllData",
 region: ROI,
 scale: 100,
 fileFormat: 'GeoTIFF',
 crs: 'EPSG:32620',
 maxPixels:1e13
 });

1 Answer 1

2

In this case you don't need to call .reproject() at all. The reprojection is implied by the crs parameter in the Export.image.toDrive() function of your script.

Per the Projections section of the Developer Guide:

As with scale, the projection in which computations take place is determined on a "pull" basis. Specifically, inputs are requested in the output projection. The output may be determined from a function parameter (e.g. crs), the Map in the Code Editor (which has a maps mercator (EPSG:3857) projection), or with a reproject() call.

Since you are requesting outputs be in the 'EPSG:32620' projection, Earth Engine will reproject upon export.

Just and additional note, there is no need to set a projection before calling .reduceResolution(), even if your data "have no projection", they always default to 'EPSG:4326' unless a different crs is provided as an argument to a function offering it as a parameter.

Here is all you need:

var AllData = LandsatComposite.addBands(Temp)
  .addBands(Elevation).toFloat()
  .reduceResolution({reducer: ee.Reducer.mean()})

Export.image.toDrive({
  image: AllData.select('B1', 'B2', 'B3', 'Temp', 'Elevation').updateMask(mask),
  description: "AllData",
  region: ROI,
  scale: 100,
  fileFormat: 'GeoTIFF',
  crs: 'EPSG:32620',
  maxPixels: 1e13
});
1
  • This is great, thanks!
    – LAT
    Commented Feb 10, 2020 at 18:16

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.