ارسال بازخورد
ee.FeatureCollection.cluster
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
هر ویژگی در یک مجموعه را خوشه بندی می کند، و یک ستون جدید به هر ویژگی شامل شماره خوشه ای که به آن اختصاص داده شده است اضافه می کند.
استفاده برمی گرداند FeatureCollection. cluster (clusterer, outputName )
مجموعه ویژگی ها
استدلال تایپ کنید جزئیات این: features
مجموعه ویژگی ها مجموعه ای از ویژگی ها برای خوشه. هر ویژگی باید شامل تمام خصوصیات طرحواره خوشه باشد. clusterer
خوشه خوشه برای استفاده. outputName
رشته، پیش فرض: "خوشه" نام ویژگی خروجی که باید اضافه شود.
نمونه ها ویرایشگر کد (جاوا اسکریپت)
// Import a Sentinel-2 surface reflectance image.
var image = ee . Image ( 'COPERNICUS/S2_SR/20210109T185751_20210109T185931_T10SEG' );
// Get the image geometry to define the geographical bounds of a point sample.
var imageBounds = image . geometry ();
// Sample the image at a set of random points; a feature collection is returned.
var pointSampleFc = image . sample (
{ region : imageBounds , scale : 20 , numPixels : 1000 , geometries : true });
// Instantiate a k-means clusterer and train it.
var clusterer = ee . Clusterer . wekaKMeans ( 5 ). train ( pointSampleFc );
// Cluster the input using the trained clusterer; optionally specify the name
// of the output cluster ID property.
var clusteredFc = pointSampleFc . cluster ( clusterer , 'spectral_cluster' );
print ( 'Note added "spectral_cluster" property for an example feature' ,
clusteredFc . first (). toDictionary ());
// Visualize the clusters by applying a unique color to each cluster ID.
var palette = ee . List ([ '8dd3c7' , 'ffffb3' , 'bebada' , 'fb8072' , '80b1d3' ]);
var clusterVis = clusteredFc . map ( function ( feature ) {
return feature . set ( 'style' , {
color : palette . get ( feature . get ( 'spectral_cluster' )),
});
}). style ({ styleProperty : 'style' });
// Display the points colored by cluster ID with the S2 image.
Map . setCenter ( - 122.35 , 37.47 , 9 );
Map . addLayer ( image , { bands : [ 'B4' , 'B3' , 'B2' ], min : 0 , max : 1500 }, 'S2 image' );
Map . addLayer ( clusterVis , null , 'Clusters' ); راه اندازی پایتون
برای اطلاعات در مورد API پایتون و استفاده از geemap
برای توسعه تعاملی به صفحه محیط پایتون مراجعه کنید.
import ee
import geemap.core as geemap کولب (پایتون)
# Import a Sentinel-2 surface reflectance image.
image = ee . Image ( 'COPERNICUS/S2_SR/20210109T185751_20210109T185931_T10SEG' )
# Get the image geometry to define the geographical bounds of a point sample.
image_bounds = image . geometry ()
# Sample the image at a set of random points a feature collection is returned.
point_sample_fc = image . sample (
region = image_bounds , scale = 20 , numPixels = 1000 , geometries = True
)
# Instantiate a k-means clusterer and train it.
clusterer = ee . Clusterer . wekaKMeans ( 5 ) . train ( point_sample_fc )
# Cluster the input using the trained clusterer optionally specify the name
# of the output cluster ID property.
clustered_fc = point_sample_fc . cluster ( clusterer , 'spectral_cluster' )
display (
'Note added "spectral_cluster" property for an example feature' ,
clustered_fc . first () . toDictionary (),
)
# Visualize the clusters by applying a unique color to each cluster ID.
palette = ee . List ([ '8dd3c7' , 'ffffb3' , 'bebada' , 'fb8072' , '80b1d3' ])
cluster_vis = clustered_fc . map (
lambda feature : feature . set (
'style' , { 'color' : palette . get ( feature . get ( 'spectral_cluster' ))}
)
) . style ( styleProperty = 'style' )
# Display the points colored by cluster ID with the S2 image.
m = geemap . Map ()
m . set_center ( - 122.35 , 37.47 , 9 )
m . add_layer (
image , { 'bands' : [ 'B4' , 'B3' , 'B2' ], 'min' : 0 , 'max' : 1500 }, 'S2 image'
)
m . add_layer ( cluster_vis , None , 'Clusters' )
m
ارسال بازخورد
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی.
میخواهید موارد بیشتری را با ما درمیان بگذارید؟
[[["درک آسان","easyToUnderstand","thumb-up"],["مشکلم را برطرف کرد","solvedMyProblem","thumb-up"],["غیره","otherUp","thumb-up"]],[["اطلاعاتی که نیاز دارم وجود ندارد","missingTheInformationINeed","thumb-down"],["بیشازحد پیچیده/ مراحل بسیار زیاد","tooComplicatedTooManySteps","thumb-down"],["قدیمی","outOfDate","thumb-down"],["مشکل ترجمه","translationIssue","thumb-down"],["مشکل کد / نمونهها","samplesCodeIssue","thumb-down"],["غیره","otherDown","thumb-down"]],["تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی."],[[["Groups features within a collection into clusters based on a provided clusterer."],["Assigns each feature a cluster ID, stored in a new property with a user-defined name (defaults to \"cluster\")."],["Requires a trained clusterer and a FeatureCollection where each feature contains the necessary properties for clustering."],["Returns a new FeatureCollection with the added cluster ID property."]]],[]]