parevalo / gee-ccdc-tools

Tools and Earth Engine apps to interact with the outputs from the CCDC algorithm
MIT License
72 stars 32 forks source link

Mysterious 'null' output in change detection part for no apparent reason #2

Closed S-AQ closed 3 years ago

S-AQ commented 3 years ago

Dear CCDC team,

I was going about the change detection part algorithm by testing some points of interest when all of a sudden one point resulted in the output null for all output variables. I wasn't entirely sure about whether to post the issue here or whether to put it on Stack Exchange, so my apologies if this is off-topic.

The problem occurs for the coordinates of 80 deg longitude and 40 deg latitude, so somewhere in the Taklamakan Desert in NW China. I tried a bunch of points with the exact same input parameters, but I only had the error for this point in particular.

// Define the point that causes an error
var errorPoint = ee.Geometry.Point(80,40);

// First load the API file
var utils = require('users/parevalo_bu/gee-ccdc-tools:ccdcUtilities/api');

// Define parameters
// Change detection parameters
var changeDetection = {
  breakpointBands: ['GREEN','RED','NIR','SWIR1','SWIR2'],
  tmaskBands: ['GREEN','SWIR2'],
  minObservations: 6,
  chiSquareProbability: 0.99,
  minNumOfYearsScaler: 1.33,
  dateFormat: 1, // 1 = fractional years
  lambda: 20/10000,
  maxIterations: 25000
};

// Define input parameters for the CCDC main function.
var params = {
  start: '2000-01-01',
  end: '2020-01-01',
  ChangeDetection: changeDetection,
  StudyRegion: errorPoint
};

// Filter by date and a location
var filteredLandsat = utils.Inputs.getLandsat()
    .filterBounds(params.StudyRegion)
    .filterDate(params.start, params.end);
print(filteredLandsat);

The problem by now is not that there are not enough images available. print(filteredLandsat) yields ImageCollection 1006 elements).

// Attach the collection to the input paramters
params.ChangeDetection['collection'] = filteredLandsat;

// Run the CCDC algorithm
var results = ee.Algorithms.TemporalSegmentation.Ccdc(params.ChangeDetection);

// Reduce results to dictionary
var firstDictionary = results.reduceRegion({
  reducer: ee.Reducer.first(),
  geometry: ee.Geometry.Point(80,40),
  scale: 30,
  maxPixels: 1e9
});
print(firstDictionary);

// Reduce results to FeatureCollection
var outputByPoints = results.reduceRegions({
  collection: params.StudyRegion,
  reducer: ee.Reducer.first(),
  scale: 30
});
print(outputByPoints);

When I print the reduced output, it returns null for all 47 properties. I don't think the problem is with the reduction itself because when I try the script with another set of points it works fine. Like for instance with this feature collection:


ee.FeatureCollection([
  ee.Feature(ee.Geometry.Point(-60,-20), {'id': 0}),
  ee.Feature(ee.Geometry.Point(140,-20), {'id': 1}),
  ee.Feature(ee.Geometry.Point(-70,10), {'id': 2}),
  ee.Feature(ee.Geometry.Point(10,50), {'id': 3}),
  ee.Feature(ee.Geometry.Point(20, -10), {'id': 4})
])```

Something seems broken but I have no idea as to what it might be.
parevalo commented 3 years ago

There is indeed an issue with retrieving your CCDC results for that particular pixel, but the error has nothing to do without tools as far as I can tell, since the rest of the results are computed just fine. If you load the CCDC results as a layer, load the problematic point and click on the inspector you'll get something like this: An internal error has occurred (request: c9864865-ed10-468e-823b-52d26bde8144) which is typically some internal error in GEE that we cannot solve. You might need to post this on the GEE Google Group, or just ignore that one point.