This feature is made up of department of senegal
var departement = ee.FeatureCollection("users/ndmorndiaye/senegal_dep");
// add area of department km2
var sup=function(feature){
return ee.Feature(feature).set({areaha:feature.geometry().area().divide(1000*1000)
})};
// Spread on all feature in collection feature feature
var dep_new=departement.map(sup);
// take a look in change i made
print("new departement",dep_new);
var centroid=function(feature){
var prop=["DEPT","REG","STATUT","areaha"]
return ee.Feature(feature.geometry().centroid()).copyProperties(feature,prop)
};
// Applicate the fuction in all fearture collection
var dep_centroids=dep_new.map(centroid);
print("centroids:",dep_centroids);
Map.centerObject(departement,6)
Map.addLayer(ee.Image().paint(departement,"black",1),{},"Limit Department")
Map.addLayer(dep_centroids,{},"departement centroids");
link:earth engine link