I am trying to do a simple "area of deforestation per year" computation in GEE, that is, applying a grouped sum reducer of a "year of deforestation" variable coming from the Tropical Moist Forest dataset. However, whenever the scale argument to reducer is wider than the original scale of the data, the output will give values such as year 0.123, for 7691 different weird year values.

I had to do following steps:

  1. I had to realize that the TMF layer is inconveniently set with the mean pyramiding policy. To figured that out, I had to resort to using earthengine asset info in python script to verify this (it seems not doable from the Java API), using this solution: How to determine pyramiding policy?.
  2. Looking at Can I change Earth Engine's pyramid scheme for a dataset?, I tried to use reduceResolution to change to a mode pyramiding policy,
  3. I ran into a problem of "The input to reduceResolution does not have a valid default projection.", which I solved with reduceResolution failes in Google Earth Engine

I thought this would be all good... but despite all these tricky and cumbersome issues, I still get weird years. The results is slightly better, as the first year is now 1997.0355, and I only get 1677 years, but still, what's going on?

Link to code: https://code.earthengine.google.com/09f39992a799f1747a68f2d94bdca1f6

var geom_1 = ee.Geometry.Polygon([[[-73.83, 2.43] ,[-73.83, 2.02],
                                        [-73.14, 2.02],[-73.14, 2.43]]])

var TMF = ee.ImageCollection('projects/JRC/TMF/v1_2021/DeforestationYear')
var TMF_mosaic = TMF.mosaic().select(["DeforestationYear"])

var pixel_area_img = ee.Image.pixelArea().divide(1000000).rename("area")
var pixel_area_forest_TMF = pixel_area_img.addBands(TMF_mosaic)

// Need to change pyramid policy
// Need first to get the right projection, mosaic() won't give it
var proj_TMF = ee.Image(TMF.first()).projection()

var pixel_area_forest_TMF_mode = pixel_area_forest_TMF
    .reproject({crs: proj_TMF})
      reducer: ee.Reducer.mode(),
      maxPixels: 2056

// now can reduce!?
var out_histo = pixel_area_forest_TMF_mode.reduceRegion({
      reducer: ee.Reducer.sum().group(1, "DeforestationYear"),
      geometry: geom_1,
      scale: 500,
      maxPixels: 10e12}).get("groups")


1 Answer 1


I think you're right that the images weren't ingested with the correct pyramid policy. The ingestion process is irreversible, so you can't fix this without re-uploading the data (or exporting at original resolution).

But you can just force all operations to work on the original, un-averaged pixels by specifying a crs equal to one of the images' original projection. (make sure you get the projection of an individual image and not a mosaic).

  • thanks for your fast reply! Your answer seems to contradict your previous answer on gis.stackexchange.com/questions/428739/… where you were hinting that yes it is possible to change the pyramiding policy... do you mind elaborating on this? And also, could you confirm that it is (not) possible to see the pyramiding policy of a given dataset on the Java API (cf gis.stackexchange.com/questions/436788/…)? Thanks so much!!
    – Matifou
    Commented Nov 4, 2023 at 21:31
  • You can (re)generate the equivalent of a single slice of the pyramid using reduceResolution, but that's not what you asked for; you asked about regenerating the whole pyramid. That's not possible except through a new Export/Import using the original full-resolution data. But really, I don't think you want either of those. It sounds like you should just do the aggregation at the native resolution. Anything else will be a (gross) approximation. Commented Nov 6, 2023 at 19:55

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.