ประกาศ: โปรเจ็กต์ที่ไม่ใช่เชิงพาณิชย์ทั้งหมดที่ลงทะเบียนเพื่อใช้ Earth Engine ก่อนวันที่ 
15 เมษายน 2025 ต้อง
ยืนยันการมีสิทธิ์ที่ไม่ใช่เชิงพาณิชย์เพื่อรักษาสิทธิ์เข้าถึง หากคุณไม่ยืนยันภายในวันที่ 26 กันยายน 2025 ระบบอาจระงับสิทธิ์เข้าถึงของคุณ
  
        
 
       
     
  
  
  
    
  
  
  
    
      ee.FeatureCollection.classify
    
    
      
    
    
      
      จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
    
    
      
      บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
    
  
  
      
    
  
  
  
  
  
    
  
  
    
    
    
  
  
จัดประเภทฟีเจอร์แต่ละรายการในคอลเล็กชัน
| การใช้งาน | การคืนสินค้า | 
|---|
| FeatureCollection.classify(classifier, outputName) | FeatureCollection | 
| อาร์กิวเมนต์ | ประเภท | รายละเอียด | 
|---|
| ดังนี้ features | FeatureCollection | ชุดฟีเจอร์ที่จะจัดประเภท ฟีเจอร์แต่ละรายการต้องมีพร็อพเพอร์ตี้ทั้งหมดในสคีมาของตัวแยกประเภท | 
| classifier | ตัวแยกประเภท | ตัวแยกประเภทที่จะใช้ | 
| outputName | สตริง ค่าเริ่มต้น: "การจัดประเภท" | ชื่อของพร็อพเพอร์ตี้เอาต์พุตที่จะเพิ่ม ระบบจะละเว้นอาร์กิวเมนต์นี้หากตัวแยกประเภทมีเอาต์พุตมากกว่า 1 รายการ | 
  
  
  ตัวอย่าง
  
    
  
  
    
    
  
  
  
  
    
    
    
      โปรแกรมแก้ไขโค้ด (JavaScript)
    
    
  /**
 * Classifies features in a FeatureCollection and computes an error matrix.
 */
// Combine Landsat and NLCD images using only the bands representing
// predictor variables (spectral reflectance) and target labels (land cover).
var spectral =
    ee.Image('LANDSAT/LC08/C02/T1_L2/LC08_038032_20160820').select('SR_B[1-7]');
var landcover =
    ee.Image('USGS/NLCD_RELEASES/2016_REL/2016').select('landcover');
var sampleSource = spectral.addBands(landcover);
// Sample the combined images to generate a FeatureCollection.
var sample = sampleSource.sample({
  region: spectral.geometry(),  // sample only from within Landsat image extent
  scale: 30,
  numPixels: 2000,
  geometries: true
})
// Add a random value column with uniform distribution for hold-out
// training/validation splitting.
.randomColumn({distribution: 'uniform'});
print('Sample for classifier development', sample);
// Split out ~80% of the sample for training the classifier.
var training = sample.filter('random < 0.8');
print('Training set', training);
// Train a random forest classifier.
var classifier = ee.Classifier.smileRandomForest(10).train({
  features: training,
  classProperty: landcover.bandNames().get(0),
  inputProperties: spectral.bandNames()
});
// Classify the sample.
var predictions = sample.classify(
    {classifier: classifier, outputName: 'predicted_landcover'});
print('Predictions', predictions);
// Split out the validation feature set.
var validation = predictions.filter('random >= 0.8');
print('Validation set', validation);
// Get a list of possible class values to use for error matrix axis labels.
var order = sample.aggregate_array('landcover').distinct().sort();
print('Error matrix axis labels', order);
// Compute an error matrix that compares predicted vs. expected values.
var errorMatrix = validation.errorMatrix({
  actual: landcover.bandNames().get(0),
  predicted: 'predicted_landcover',
  order: order
});
print('Error matrix', errorMatrix);
// Compute accuracy metrics from the error matrix.
print("Overall accuracy", errorMatrix.accuracy());
print("Consumer's accuracy", errorMatrix.consumersAccuracy());
print("Producer's accuracy", errorMatrix.producersAccuracy());
print("Kappa", errorMatrix.kappa());
  
    
  
  
    
  
  
  
  
    
  
    
  การตั้งค่า Python
  ดูข้อมูลเกี่ยวกับ Python API และการใช้ geemap เพื่อการพัฒนาแบบอินเทอร์แอกทีฟได้ที่หน้า
    สภาพแวดล้อม Python
  import ee
import geemap.core as geemap
  
    
    
      Colab (Python)
    
    
  # Classifies features in a FeatureCollection and computes an error matrix.
# Combine Landsat and NLCD images using only the bands representing
# predictor variables (spectral reflectance) and target labels (land cover).
spectral = ee.Image('LANDSAT/LC08/C02/T1_L2/LC08_038032_20160820').select(
    'SR_B[1-7]')
landcover = ee.Image('USGS/NLCD_RELEASES/2016_REL/2016').select('landcover')
sample_source = spectral.addBands(landcover)
# Sample the combined images to generate a FeatureCollection.
sample = sample_source.sample(**{
    # sample only from within Landsat image extent
    'region': spectral.geometry(),
    'scale': 30,
    'numPixels': 2000,
    'geometries': True
})
# Add a random value column with uniform distribution for hold-out
# training/validation splitting.
sample = sample.randomColumn(**{'distribution': 'uniform'})
display('Sample for classifier development:', sample)
# Split out ~80% of the sample for training the classifier.
training = sample.filter('random < 0.8')
display('Training set:', training)
# Train a random forest classifier.
classifier = ee.Classifier.smileRandomForest(10).train(**{
    'features': training,
    'classProperty': landcover.bandNames().get(0),
    'inputProperties': spectral.bandNames()
})
# Classify the sample.
predictions = sample.classify(
    **{'classifier': classifier, 'outputName': 'predicted_landcover'})
display('Predictions:', predictions)
# Split out the validation feature set.
validation = predictions.filter('random >= 0.8')
display('Validation set:', validation)
# Get a list of possible class values to use for error matrix axis labels.
order = sample.aggregate_array('landcover').distinct().sort()
display('Error matrix axis labels:', order)
# Compute an error matrix that compares predicted vs. expected values.
error_matrix = validation.errorMatrix(**{
    'actual': landcover.bandNames().get(0),
    'predicted': 'predicted_landcover',
    'order': order
})
display('Error matrix:', error_matrix)
# Compute accuracy metrics from the error matrix.
display('Overall accuracy:', error_matrix.accuracy())
display('Consumer\'s accuracy:', error_matrix.consumersAccuracy())
display('Producer\'s accuracy:', error_matrix.producersAccuracy())
display('Kappa:', error_matrix.kappa())
  
  
  
  
  
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
  อัปเดตล่าสุด 2025-10-30 UTC
  
  
  
    
      [null,null,["อัปเดตล่าสุด 2025-10-30 UTC"],[],[]]