ประกาศ : โปรเจ็กต์ที่ไม่ใช่เชิงพาณิชย์ทั้งหมดที่ลงทะเบียนเพื่อใช้ Earth Engine ก่อนวันที่
15 เมษายน 2025 ต้อง
ยืนยันการมีสิทธิ์ที่ไม่ใช่เชิงพาณิชย์ เพื่อรักษาสิทธิ์เข้าถึง หากคุณไม่ยืนยันภายในวันที่ 26 กันยายน 2025 ระบบอาจระงับสิทธิ์เข้าถึงของคุณ
ส่งความคิดเห็น
ee.FeatureCollection.flatten
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
ทำให้คอลเล็กชันของคอลเล็กชันแบนราบ
การใช้งาน การคืนสินค้า FeatureCollection. flatten ()
FeatureCollection
อาร์กิวเมนต์ ประเภท รายละเอียด ดังนี้ collection
FeatureCollection คอลเล็กชันอินพุตของคอลเล็กชัน
ตัวอย่าง
โปรแกรมแก้ไขโค้ด (JavaScript)
// Counties in New Mexico, USA.
var counties = ee . FeatureCollection ( 'TIGER/2018/Counties' )
. filter ( 'STATEFP == "35"' );
// Monthly climate and climatic water balance surfaces for January 2020.
var climate = ee . ImageCollection ( 'IDAHO_EPSCOR/TERRACLIMATE' )
. filterDate ( '2020-01' , '2020-02' );
// Calculate mean climate variables for each county per climate surface
// time step. The result is a FeatureCollection of FeatureCollections.
var countiesClimate = climate . map ( function ( image ) {
return image . reduceRegions ({
collection : counties ,
reducer : ee . Reducer . mean (),
scale : 5000 ,
crs : 'EPSG:4326'
});
});
// Note that a printed FeatureCollection of FeatureCollections is not
// recursively expanded, you cannot view metadata of the features within the
// nested collections until you isolate a single collection or flatten the
// collections.
print ( 'FeatureCollection of FeatureCollections' , countiesClimate );
print ( 'Flattened FeatureCollection of FeatureCollections' ,
countiesClimate . flatten ());
การตั้งค่า Python
ดูข้อมูลเกี่ยวกับ Python API และการใช้ geemap
เพื่อการพัฒนาแบบอินเทอร์แอกทีฟได้ที่หน้า
สภาพแวดล้อม Python
import ee
import geemap.core as geemap
Colab (Python)
# Counties in New Mexico, USA.
counties = ee . FeatureCollection ( 'TIGER/2018/Counties' ) . filter ( 'STATEFP == "35"' )
# Monthly climate and climatic water balance surfaces for January 2020.
climate = ee . ImageCollection ( 'IDAHO_EPSCOR/TERRACLIMATE' ) . filterDate (
'2020-01' , '2020-02' )
# Calculate mean climate variables for each county per climate surface
# time step. The result is a FeatureCollection of FeatureCollections.
def reduce_mean ( image ):
return image . reduceRegions ( ** {
'collection' : counties ,
'reducer' : ee . Reducer . mean (),
'scale' : 5000 ,
'crs' : 'EPSG:4326'
})
counties_climate = climate . map ( reduce_mean )
# Note that a printed FeatureCollection of FeatureCollections is not
# recursively expanded, you cannot view metadata of the features within the
# nested collections until you isolate a single collection or flatten the
# collections.
print ( 'FeatureCollection of FeatureCollections:' , counties_climate . getInfo ())
print ( 'Flattened FeatureCollection of FeatureCollections:' ,
counties_climate . flatten () . getInfo ())
ส่งความคิดเห็น
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-26 UTC
หากต้องการบอกให้เราทราบเพิ่มเติม
[[["เข้าใจง่าย","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-26 UTC"],[],["The `flatten()` method transforms a nested `FeatureCollection` of `FeatureCollections` into a single, flat `FeatureCollection`. It takes a `FeatureCollection` as input and returns a flattened `FeatureCollection`. This allows for the metadata of features within the nested collections to be viewed, which is not possible with unflattened collections. An example demonstrates calculating mean climate variables for counties per climate surface timestep and then flattening the resulting nested collection.\n"]]