exportasyncfunctionrecommend(polygon,points,{ threshold, scaleFactor, kmeansOptions, hullOptions }){constptsWithin=turf.pointsWithinPolygon(points,polygon)// Filter by scoreconstfiltered=ptsWithin.features.filter(feature=>feature.properties.score>=threshold)if(filtered.length){// Cluster K-meansconstclustered=turf.clustersKmeans(turf.featureCollection(filtered),kmeansOptions)// Concave hull from each clusterconstvillages=turf.clusterReduce(clustered,'cluster',(previousValue,cluster)=>{consthull=turf.concave(cluster,hullOptions)// scale down the polygon (raster buffer to prevent overlapping villages)returnhull ? previousValue.concat([turf.transformScale(hull,scaleFactor)]) : previousValue},[])returnturf.featureCollection(villages)}returnturf.featureCollection([])}