eMapR / LT-GEE

Google Earth Engine implementation of the LandTrendr spectral-temporal segmentation algorithm. For documentation see:
https://emapr.github.io/LT-GEE
Apache License 2.0
198 stars 65 forks source link

.unmask on masked values adds incorrect sized array in getSegmentData #2

Closed grovduck closed 5 years ago

grovduck commented 5 years ago

Running across this issue with Landtrendr masked values when calling getSegmentData. When concatenating all the segment information, unmask is called with an ee.Array of 8 rows by 1 column. Because the segment information is not yet an array image, this 8x1 array is inserted for masked values per band, and when converted to an array image row-wise, previously masked pixels have a 64x1 array of -9999s.

I think the fix is simply to just unmasked with a single 1x1 array image, e.g.

return ee.Image.cat([startYear.add(1), endYear, startVal, endVal, mag, dur, rate, dsnr])
  .unmask(ee.Image(ee.Array([[-9999]])))
  .toArray(0);

This works for me.

jdbcode commented 5 years ago

Thanks, Matt. I made the suggested changes to LandTrendr.getSegmentData. I tested it on some areas I've found all-observations-masked issues in the past and it works fine for those. Would you mind testing the changes on your use case - if it works okay let's close this.

grovduck commented 5 years ago

Looks good on my end. Closing ...