i want to detect wildfire in earth engine. So the classification works almost very well. But now i want to determine the fire polygons, calculate their centroids and then cluster centroids which are within a certain distance. Like, if point A is near to point B and B is near to Point C. Then these three point belongs to the same fire and i want to calculate a new centroid. So, at this point i have a list with several centroids of the polygons. From this list, i calculated a nested list where every index belongs to the same index in the centroid point list. Also every entry in the nested list, has an sublist with the points within distance. For example: Centroid Point List:

[0]-> A,

[1] -> B,

[2] -> C,

[3] -> D

After calculating the within distance. The nested list is:

[0] (A) --> [[0]->A;[1]->B]

[1] (B) --> [[0]->B;[1]->A]

[2] (C) --> [[0]->C;[1]->B]

[3] (D) --> [[0]->D]

Now i want to connect A,B,C and seperate D. But i absolutely dont know how.

Here's a snippet of my code:

//Cluster centroids // Define a spatial filter, with distance 100 m. var distFilter = ee.Filter.withinDistance({ distance: 100, leftField: '.geo', rightField: '.geo', maxError: 10 }); // Define a saveAll join. var distSaveAll = ee.Join.saveAll({ matchesKey: 'points' }); // Apply the join. var spatialJoined = distSaveAll.apply(fireCentroid2Features, fireCentroid2Features, distFilter); // Nested List var test=ee.List(spatialJoined.toList(spatialJoined.size())); print(test)

fireCentroid2Features is a FeatureCollection containing the Centroids Coordinates. test is the nested List.

Your Answer

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

Browse other questions tagged or ask your own question.