ee.Geometry.Rectangle

构建一个描述矩形多边形的 ee.Geometry。

为方便起见,如果所有实参都是数字,则可以使用可变数量实参。这样,您就可以使用四个坐标(例如 ee.Geometry.Rectangle(minLng, minLat, maxLng, maxLat))创建 EPSG:4326 多边形。

用法返回
ee.Geometry.Rectangle(coords, proj, geodesic, evenOdd)Geometry.Rectangle
参数类型详细信息
coordsList<Geometry>|List<List<Number>>|List<Number>矩形的最小角和最大角,以以下形式表示:包含两个点的列表(每个点采用 GeoJSON“Point”坐标格式)、包含两个描述点的 ee.Geometry 对象的列表,或包含四个数字的列表(按 xMin、yMin、xMax、yMax 的顺序排列)。
proj投影,可选相应几何图形的投影。如果未指定,则默认为输入 ee.Geometry 的投影,如果没有 ee.Geometry 输入,则默认为 EPSG:4326。
geodesic布尔值,可选如果为 false,则投影中的边缘为直线。如果为 true,则边会弯曲,以遵循地球表面的最短路径。默认值为输入的测地线状态,如果输入为数字,则为 true。
evenOdd布尔值,可选如果为 true,则多边形内部将由偶数/奇数规则确定,即如果一个点穿过奇数条边才能到达无穷远的点,则该点位于多边形内部。否则,多边形将使用左侧内部规则,即当按给定顺序遍历顶点时,内部位于外壳边缘的左侧。如果未指定,则默认为 true。

示例

代码编辑器 (JavaScript)

// Coordinates for the bounds of a rectangle.
var xMin = -122.09;
var yMin = 37.42;
var xMax = -122.08;
var yMax = 37.43;

// Construct a rectangle from a list of GeoJSON 'point' formatted coordinates.
var rectangleGeoJSON = ee.Geometry.Rectangle(
  [
    [xMin, yMin],
    [xMax, yMax]   // max x and y
  ]
);
Map.addLayer(rectangleGeoJSON, {}, 'rectangleGeoJSON');

// Construct a rectangle from a list of ee.Geometry.Point objects.
var rectanglePoint = ee.Geometry.Rectangle(
  [
    ee.Geometry.Point(xMin, yMin),  // min x and y
    ee.Geometry.Point(xMax, yMax)   // max x and y
  ]
);
Map.addLayer(rectanglePoint, {}, 'rectanglePoint');

// Construct a rectangle from a list of bounding coordinates.
var rectangleBounds = ee.Geometry.Rectangle(
  [xMin, yMin, xMax, yMax]
);
Map.addLayer(rectangleBounds, {}, 'rectangleBounds');

Map.setCenter(-122.085, 37.422, 15);