ee.Geometry.closestPoint

แสดงผลจุดในอินพุตด้านขวาที่อยู่ใกล้กับอินพุตด้านซ้ายมากที่สุด หากอินพุตใดอินพุตหนึ่งว่างเปล่า ระบบจะแสดงผลเป็น Null หากอินพุตทั้ง 2 รายการไม่มีขอบเขต ระบบจะแสดงผลจุดที่กำหนดเอง หากอินพุตใดอินพุตหนึ่งไม่มีขอบเขต ระบบจะแสดงผลจุดใดก็ได้ในอินพุตที่มีขอบเขต

การใช้งานการคืนสินค้า
Geometry.closestPoint(right, maxError, proj)วัตถุ
อาร์กิวเมนต์ประเภทรายละเอียด
ดังนี้ leftเรขาคณิตเรขาคณิตที่ใช้เป็นตัวถูกดำเนินการด้านซ้ายของการดำเนินการ
rightเรขาคณิตเรขาคณิตที่ใช้เป็นตัวถูกดำเนินการด้านขวาของการดำเนินการ
maxErrorErrorMargin, ค่าเริ่มต้น: nullปริมาณข้อผิดพลาดสูงสุดที่ยอมรับได้เมื่อทำการฉายซ้ำที่จำเป็น
projการฉายภาพ ค่าเริ่มต้น: nullการฉายภาพที่จะใช้ดำเนินการ หากไม่ได้ระบุ ระบบจะดำเนินการในระบบพิกัดทรงกลม และระยะทางเชิงเส้นจะเป็นหน่วยเมตรบนทรงกลม

ตัวอย่าง

โปรแกรมแก้ไขโค้ด (JavaScript)

// Define a Geometry object.
var geometry = ee.Geometry({
  'type': 'Polygon',
  'coordinates':
    [[[-122.081, 37.417],
      [-122.086, 37.421],
      [-122.084, 37.418],
      [-122.089, 37.416]]]
});

// Define other inputs.
var inputGeom = ee.Geometry.Polygon(
        [[[-122.068, 37.418],
          [-122.068, 37.416],
          [-122.064, 37.416],
          [-122.064, 37.418]]]);

// Apply the closestPoints method to the Geometry objects.
var closestPoints = ee.Dictionary(geometry.closestPoints({'right': inputGeom, 'maxError': 1}));

// Print the result to the console.
print('geometry.closestPoints(...) =', closestPoints);

// There is also a one-sided API for convenience.
var closestPointOnInputGeom = geometry.closestPoint({'right': inputGeom, 'maxError': 1});
print('geometry.closestPoint(...) =', closestPointOnInputGeom);

// Display relevant geometries on the map.
Map.setCenter(-122.085, 37.422, 15);
Map.addLayer(geometry,
             {'color': 'black'},
             'Geometry [black]: geometry');
Map.addLayer(inputGeom,
             {'color': 'blue'},
             'Parameter [blue]: inputGeom');
Map.addLayer(closestPoints.getGeometry('left'),
             {'color': 'red'},
             'Result [red]: closestPointOnLeft');
Map.addLayer(closestPoints.getGeometry('right'),
             {'color': 'red'},
             'Result [red]: closestPointOnRight');