I am trying to sample image and to get scatter plot of its' two bands- NDVI and db from senttinel 1.
For some reason, probably because of the size of the shapefile, I get the error:
Error generating chart: Collection query aborted after accumulating
over 5000 elements.Collection query aborted after accumulating over 5000 elements
That's happens after I try to sample my image using this:
// Generate a sample of points within the region
var sample = pairedImage.sampleRegions(geometry, null,3);
I have playes with the last number in the funnction , I started with 50 but then went down to 30,10,5 ,1 and 3, but non of them worked and in all I have gotten the same error. is it possible that it happens because of the size of the image and there is nothing I can do?
Here is a link to my code:
https://code.earthengine.google.com/f967f358a45cc1c40ccc6d0373066270
My end goal: to be able to sample this image and create the chart
Best Answer
The collection you pass to
ui.Chart.feature.byFeature()
cannot contain more than 5000 features. In your case, yoursample
collection contains way more than 5000.This samples your image at a scale of 3 meters. Since your image comes from Sentinel 2, it’s pointless to sampling at a scale smaller than 10 meters. Sampling your geometry at 10 meters gives you more than 600,000 features. That leaves you with two options: Sample at a larger scale or sample a smaller area. The below script samples at 100 meters:
https://code.earthengine.google.com/ce8aa2625c3bdf29e583364a19994dc4