ee.Geometry.Polygon
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 ee.Geometry mô tả một đa giác.
Để thuận tiện, bạn có thể dùng varargs khi tất cả đối số đều là số. Điều này cho phép tạo Đa giác EPSG:4326 trắc địa bằng một LinearRing duy nhất với số lượng đối số chẵn, ví dụ: ee.Geometry.Polygon(aLng, aLat, bLng, bLat, ..., aLng, aLat).
Cách sử dụng | Giá trị trả về |
---|
ee.Geometry.Polygon(coords, proj, geodesic, maxError, evenOdd) | Geometry.Polygon |
Đối số | Loại | Thông tin chi tiết |
---|
coords | List<Geometry>|List<List<List<Number>>>|List<Number> | Một danh sách các vòng xác định ranh giới của đa giác. Có thể là danh sách các toạ độ ở định dạng "Đa giác" GeoJSON, danh sách các đối tượng ee.Geometry mô tả một LinearRing hoặc danh sách các số xác định một ranh giới đa giác duy nhất. |
proj | Dự kiến (không bắt buộc) | Phép chiếu của hình học này. Giá trị mặc định là phép chiếu của các đầu vào, trong đó các Số được giả định là EPSG:4326. |
geodesic | Boolean, không bắt buộc | Nếu là false, các cạnh sẽ thẳng trong phép chiếu. Nếu là true, các cạnh sẽ được uốn cong để đi theo đường ngắn nhất trên bề mặt Trái Đất. Giá trị mặc định là trạng thái trắc địa của các giá trị đầu vào hoặc true nếu các giá trị đầu vào là số. |
maxError | ErrorMargin (không bắt buộc) | Lỗi tối đa khi hình học đầu vào phải được chiếu lại thành một phép chiếu kết quả hoặc trạng thái trắc địa được yêu cầu rõ ràng. |
evenOdd | Boolean, không bắt buộc | Nếu đúng, phần bên trong đa giác sẽ được xác định theo quy tắc chẵn/lẻ, trong đó một điểm nằm bên trong nếu điểm đó cắt một số cạnh lẻ để đến một điểm ở vô cực. Nếu không, các đa giác sẽ sử dụng quy tắc bên trái, trong đó nội thất nằm ở phía bên trái của các cạnh của lớp vỏ khi đi qua các đỉnh theo thứ tự đã cho. Nếu bạn không chỉ định, giá trị mặc định sẽ là true. |
Ví dụ
Trình soạn thảo mã (JavaScript)
// Construct a polygon from a list of GeoJSON 'Polygon' formatted coordinates.
var polygonGeoJSON = ee.Geometry.Polygon(
[
[ // exterior ring
[100.0, 0.0],
[103.0, 0.0],
[103.0, 3.0],
[100.0, 3.0],
[100.0, 0.0] // matching the first vertex is optional
],
[ // interior ring
[101.0, 1.0],
[102.0, 2.0],
[102.0, 1.0]
]
]
);
Map.addLayer(polygonGeoJSON, {}, 'polygonGeoJSON');
// Construct a polygon from an ee.Geometry.LinearRing.
var polygonLinearRing = ee.Geometry.Polygon(
[
ee.Geometry.LinearRing(
[
[105.0, 0.0],
[108.0, 0.0],
[108.0, 3.0]
]
)
]
);
Map.addLayer(polygonLinearRing, {}, 'polygonLinearRing');
// Construct a polygon from a list of x,y coordinate pairs defining a boundary.
var polygonCoordList = ee.Geometry.Polygon(
[110.0, 0.0, 113.0, 0.0, 110.0, 3.0]
);
Map.addLayer(polygonCoordList, {}, 'polygonCoordList');
Map.centerObject(polygonLinearRing);
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.
[null,null,["Cập nhật lần gần đây nhất: 2025-07-25 UTC."],[[["\u003cp\u003e\u003ccode\u003eee.Geometry.Polygon\u003c/code\u003e constructs a polygon geometry in Earth Engine, accepting coordinates, projection, geodesic, max error, and even/odd parameters for customization.\u003c/p\u003e\n"],["\u003cp\u003eInput coordinates can be provided as GeoJSON 'Polygon' format, a list of \u003ccode\u003eee.Geometry.LinearRing\u003c/code\u003e objects, or a list of coordinate pairs for the boundary.\u003c/p\u003e\n"],["\u003cp\u003eBy default, the projection is derived from inputs (numbers assumed as EPSG:4326), edges are straight unless \u003ccode\u003egeodesic\u003c/code\u003e is true, and interiors are determined using the even/odd rule.\u003c/p\u003e\n"],["\u003cp\u003eOptional parameters allow for specifying projection, geodesic behavior, maximum error for reprojection, and even/odd rule for polygon interiors.\u003c/p\u003e\n"],["\u003cp\u003eConveniently, polygons can be created with a single LinearRing using varargs for providing coordinate pairs in EPSG:4326.\u003c/p\u003e\n"]]],["This describes the `ee.Geometry.Polygon` constructor, which creates a polygon geometry. Key actions include defining polygon boundaries using a list of rings (in GeoJSON format, as `ee.Geometry.LinearRing` objects, or coordinate pairs). The constructor accepts optional parameters: `proj` (projection), `geodesic` (edge curvature), `maxError` (reprojection error), and `evenOdd` (interior rule). Default values are provided if the parameters are omitted, and the input arguments dictate them.\n"],null,["# ee.Geometry.Polygon\n\n\u003cbr /\u003e\n\nConstructs an ee.Geometry describing a polygon.\n\n\u003cbr /\u003e\n\nFor convenience, varargs may be used when all arguments are numbers. This allows creating geodesic EPSG:4326 Polygons with a single LinearRing given an even number of arguments, e.g. ee.Geometry.Polygon(aLng, aLat, bLng, bLat, ..., aLng, aLat).\n\n| Usage | Returns |\n|-------------------------------------------------------------------------------------|------------------|\n| `ee.Geometry.Polygon(coords, `*proj* `, `*geodesic* `, `*maxError* `, `*evenOdd*`)` | Geometry.Polygon |\n\n| Argument | Type | Details |\n|------------|------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `coords` | List\\\u003cGeometry\\\u003e\\|List\\\u003cList\\\u003cList\\\u003cNumber\\\u003e\\\u003e\\\u003e\\|List\\\u003cNumber\\\u003e | A list of rings defining the boundaries of the polygon. May be a list of coordinates in the GeoJSON 'Polygon' format, a list of ee.Geometry objects describing a LinearRing, or a list of numbers defining a single polygon boundary. |\n| `proj` | Projection, optional | The projection of this geometry. The default is the projection of the inputs, where Numbers are assumed to be EPSG:4326. |\n| `geodesic` | Boolean, optional | If false, edges are straight in the projection. If true, edges are curved to follow the shortest path on the surface of the Earth. The default is the geodesic state of the inputs, or true if the inputs are numbers. |\n| `maxError` | ErrorMargin, optional | Max error when input geometry must be reprojected to an explicitly requested result projection or geodesic state. |\n| `evenOdd` | Boolean, optional | If true, polygon interiors will be determined by the even/odd rule, where a point is inside if it crosses an odd number of edges to reach a point at infinity. Otherwise polygons use the left- inside rule, where interiors are on the left side of the shell's edges when walking the vertices in the given order. If unspecified, defaults to true. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// Construct a polygon from a list of GeoJSON 'Polygon' formatted coordinates.\nvar polygonGeoJSON = ee.Geometry.Polygon(\n [\n [ // exterior ring\n [100.0, 0.0],\n [103.0, 0.0],\n [103.0, 3.0],\n [100.0, 3.0],\n [100.0, 0.0] // matching the first vertex is optional\n ],\n [ // interior ring\n [101.0, 1.0],\n [102.0, 2.0],\n [102.0, 1.0]\n ]\n ]\n);\nMap.addLayer(polygonGeoJSON, {}, 'polygonGeoJSON');\n\n// Construct a polygon from an ee.Geometry.LinearRing.\nvar polygonLinearRing = ee.Geometry.Polygon(\n [\n ee.Geometry.LinearRing(\n [\n [105.0, 0.0],\n [108.0, 0.0],\n [108.0, 3.0]\n ]\n )\n ]\n);\nMap.addLayer(polygonLinearRing, {}, 'polygonLinearRing');\n\n// Construct a polygon from a list of x,y coordinate pairs defining a boundary.\nvar polygonCoordList = ee.Geometry.Polygon(\n [110.0, 0.0, 113.0, 0.0, 110.0, 3.0]\n);\nMap.addLayer(polygonCoordList, {}, 'polygonCoordList');\n\nMap.centerObject(polygonLinearRing);\n```"]]