Thông báo : Tất cả dự án phi thương mại đã đăng ký sử dụng Earth Engine trước
ngày 15 tháng 4 năm 2025 phải
xác minh điều kiện sử dụng phi thương mại để duy trì quyền truy cập. Nếu bạn chưa xác minh trước ngày 26 tháng 9 năm 2025, quyền truy cập của bạn có thể bị tạm ngưng.
Gửi ý kiến phản hồi
Export.classifier.toAsset
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Tạo một tác vụ hàng loạt để xuất ee.Classifier dưới dạng một tài sản Earth Engine.
Chỉ hỗ trợ cho ee.Classifier.smileRandomForest, ee.Classifier.smileCart, ee.Classifier.DecisionTree và ee.Classifier.DecisionTreeEnsemble.
Cách sử dụng Giá trị trả về Export.classifier.toAsset(classifier, description , assetId , priority )
Đối số Loại Thông tin chi tiết classifier
ComputedObject Trình phân loại cần xuất. description
Chuỗi, không bắt buộc Tên công việc mà con người đọc được. Giá trị mặc định là "myExportClassifierTask". assetId
Chuỗi, không bắt buộc Mã thành phần đích. priority
Số, không bắt buộc Mức độ ưu tiên của công việc trong dự án. Các tác vụ có mức độ ưu tiên cao hơn sẽ được lên lịch sớm hơn. Phải là số nguyên từ 0 đến 9999. Giá trị mặc định là 100.
Ví dụ
Trình soạn thảo mã (JavaScript)
// First gather the training data for a random forest classifier.
// Let's use MCD12Q1 yearly landcover for the labels.
var landcover = ee . ImageCollection ( 'MODIS/061/MCD12Q1' )
. filterDate ( '2022-01-01' , '2022-12-31' )
. first ()
. select ( 'LC_Type1' );
// A region of interest for training our classifier.
var region = ee . Geometry . BBox ( 17.33 , 36.07 , 26.13 , 43.28 );
// Training features will be based on a Landsat 8 composite.
var l8 = ee . ImageCollection ( 'LANDSAT/LC08/C02/T1' )
. filterBounds ( region )
. filterDate ( '2022-01-01' , '2023-01-01' );
// Draw the Landsat composite, visualizing true color bands.
var landsatComposite = ee . Algorithms . Landsat . simpleComposite ({
collection : l8 ,
asFloat : true
});
Map . addLayer ( landsatComposite , {
min : 0 ,
max : 0.3 ,
bands : [ 'B3' , 'B2' , 'B1' ]
}, 'Landsat composite' );
// Make a training dataset by sampling the stacked images.
var training = landcover . addBands ( landsatComposite ). sample ({
region : region ,
scale : 30 ,
// With export to Classifier we can bump this higher to say 10,000.
numPixels : 1000
});
var classifier = ee . Classifier . smileRandomForest ({
// We can also increase the number of trees higher to ~100 if needed.
numberOfTrees : 3
}). train ({ features : training , classProperty : 'LC_Type1' });
// Create an export classifier task to run.
var assetId = 'projects/<project-name>/assets/<asset-name>' ; // <> modify these
Export . classifier . toAsset ({
classifier : classifier ,
description : 'classifier_export' ,
assetId : assetId
});
// Load the classifier after the export finishes and visualize.
var savedClassifier = ee . Classifier . load ( assetId )
var landcoverPalette = '05450a,086a10,54a708,78d203,009900,c6b044,dcd159,' +
'dade48,fbff13,b6ff05,27ff87,c24f44,a5a5a5,ff6d4c,69fff8,f9ffa4,1c0dff' ;
var landcoverVisualization = {
palette : landcoverPalette ,
min : 0 ,
max : 16 ,
format : 'png'
};
Map . addLayer (
landsatComposite . classify ( savedClassifier ),
landcoverVisualization ,
'Upsampled landcover, saved' );
Thiết lập Python
Hãy xem trang
Môi trường Python để biết thông tin về API Python và cách sử dụng geemap
để phát triển tương tác.
import ee
import geemap.core as geemap
Colab (Python)
# First gather the training data for a random forest classifier.
# Let's use MCD12Q1 yearly landcover for the labels.
landcover = ( ee . ImageCollection ( 'MODIS/061/MCD12Q1' )
. filterDate ( '2022-01-01' , '2022-12-31' )
. first ()
. select ( 'LC_Type1' ))
# A region of interest for training our classifier.
region = ee . Geometry . BBox ( 17.33 , 36.07 , 26.13 , 43.28 )
# Training features will be based on a Landsat 8 composite.
l8 = ( ee . ImageCollection ( 'LANDSAT/LC08/C02/T1' )
. filterBounds ( region )
. filterDate ( '2022-01-01' , '2023-01-01' ))
# Draw the Landsat composite, visualizing true color bands.
landsatComposite = ee . Algorithms . Landsat . simpleComposite (
collection = l8 , asFloat = True )
Map = geemap . Map ()
Map # Render the map in the notebook.
Map . addLayer ( landsatComposite , {
'min' : 0 ,
'max' : 0.3 ,
'bands' : [ 'B3' , 'B2' , 'B1' ]
}, 'Landsat composite' )
# Make a training dataset by sampling the stacked images.
training = landcover . addBands ( landsatComposite ) . sample (
region = region ,
scale = 30 ,
# With export to Classifier we can bump this higher to say 10,000.
numPixels = 1000
)
# We can also increase the number of trees higher to ~100 if needed.
classifier = ee . Classifier . smileRandomForest (
numberOfTrees = 3 ) . train ( features = training , classProperty = 'LC_Type1' )
# Create an export classifier task to run.
asset_id = 'projects/<project-name>/assets/<asset-name>' # <> modify these
ee . batch . Export . classifier . toAsset (
classifier = classifier ,
description = 'classifier_export' ,
assetId = asset_id
)
# Load the classifier after the export finishes and visualize.
savedClassifier = ee . Classifier . load ( asset_id )
landcover_palette = [
'05450a' , '086a10' , '54a708' , '78d203' , '009900' ,
'c6b044' , 'dcd159' , 'dade48' , 'fbff13' , 'b6ff05' ,
'27ff87' , 'c24f44' , 'a5a5a5' , 'ff6d4c' , '69fff8' ,
'f9ffa4' , '1c0dff' ]
landcoverVisualization = {
'palette' : landcover_palette ,
'min' : 0 ,
'max' : 16 ,
'format' : 'png'
}
Map . addLayer (
landsatComposite . classify ( savedClassifier ),
landcoverVisualization ,
'Upsampled landcover, saved' )
Gửi ý kiến phản hồi
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0 . Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers . Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-07-25 UTC.
Bạn muốn chia sẻ thêm với chúng tôi?
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-07-25 UTC."],[],["This content details exporting an `ee.Classifier` as an Earth Engine asset using `Export.classifier.toAsset`. Key actions include: creating a classifier, defining a training dataset using landcover data and Landsat composites, sampling training data, and then training the classifier. The export process involves specifying the `classifier`, `description`, `assetId`, and `priority`. After export, the saved classifier can be loaded and used for classification, then visualized.\n"]]