0

I have raster with NDVI values and I would like to use reducer in order to know how many pixels in the raster are smaller than 0.2, between 0.2-0.4 , betwen 0.4-0.6 and gt than 0.6.

i'm not sure that the way I have been that gives me true results, because I have difference between the total number of pixels to the sum of the differnt categories pixel counts.

    var c0406 = image.gt(0.4).lt(0.6).selfMask().reduceRegion({
    reducer: ee.Reducer.count(),
    geometry: geometry,
    crs: 'EPSG:4326',
    //maxPixels:1310361348,
    scale: 20,
  }).values().get(0);

when each time I have change the condition in image.gt

I'm not sure it's correct because when I calculte the total number of pixels, I get 17,748 , but when I calculte the categories pixels I get around 45k:

   var total = image.reduceRegion({
    reducer: ee.Reducer.count(),
    geometry: geometry,
    crs: 'EPSG:4326',
    //maxPixels:1310361348,
    scale: 30,
  }).values().get(0);

enter image description here

*i'm not sure what is systen asset size and if it's also suppose to be number of pixels

My end goal is to count correctly the number of pixels between different ranges (0.2-0.4 ect.)

1 Answer 1

1

You have different scales in the two reduceRegion() calls. One is using 30 meters, the other 20 meters. With a scale of 20 meters you would get more pixels than with a scale of 30 meters.

1
  • you are right about this, I fixed it, but still getting total of 39876 and when I manually sum the different ranges I get 45,576 . (fixed everything so scale is 20 in all the ranges)
    – Reut
    Mar 19, 2020 at 10:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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