โปรดทราบว่าระบบจะวัดระยะทางภายในรูปหลายเหลี่ยมด้วย ระบบจะมาสก์พิกเซลที่อยู่นอกรัศมี "searchRadius" เมตรของรูปทรงเรขาคณิต
ระยะทางจะคำนวณบนทรงกลม จึงอาจมีข้อผิดพลาดเล็กน้อยตามสัดส่วนของความแตกต่างของละติจูดระหว่างแต่ละพิกเซลกับรูปเรขาคณิตที่ใกล้ที่สุด
| การใช้งาน | การคืนสินค้า |
|---|---|
FeatureCollection.distance(searchRadius, maxError) | รูปภาพ |
| อาร์กิวเมนต์ | ประเภท | รายละเอียด |
|---|---|---|
features | FeatureCollection | ชุดฟีเจอร์ที่จะใช้ในการคำนวณระยะทางของพิกเซล |
searchRadius | Float, ค่าเริ่มต้น: 100000 | ระยะทางสูงสุดเป็นเมตรจากแต่ละพิกเซลเพื่อค้นหาขอบ ระบบจะมาสก์พิกเซล เว้นแต่จะมีขอบภายในระยะทางนี้ |
maxError | Float, ค่าเริ่มต้น: 100 | ข้อผิดพลาดในการฉายซ้ำสูงสุดเป็นเมตร ใช้เฉพาะในกรณีที่เส้นหลายเส้นอินพุตต้องมีการฉายซ้ำ หากระบุเป็น "0" การดำเนินการนี้จะล้มเหลวหากต้องมีการฉายภาพ |
ตัวอย่าง
ตัวแก้ไขโค้ด (JavaScript)
// FeatureCollection of power plants in Belgium. var fc = ee.FeatureCollection('WRI/GPPD/power_plants') .filter('country_lg == "Belgium"'); // Generate an image of distance to nearest power plant. var distance = fc.distance({searchRadius: 50000, maxError: 50}); // Display the image and FeatureCollection on the map. Map.setCenter(4.56, 50.78, 7); Map.addLayer(distance, {max: 50000}, 'Distance to power plants'); Map.addLayer(fc, {color: 'red'}, 'Power plants');
import ee import geemap.core as geemap
Colab (Python)
# FeatureCollection of power plants in Belgium. fc = ee.FeatureCollection('WRI/GPPD/power_plants').filter( 'country_lg == "Belgium"' ) # Generate an image of distance to nearest power plant. distance = fc.distance(searchRadius=50000, maxError=50) # Display the image and FeatureCollection on the map. m = geemap.Map() m.set_center(4.56, 50.78, 7) m.add_layer(distance, {'max': 50000}, 'Distance to power plants') m.add_layer(fc, {'color': 'red'}, 'Power plants') m