Anuncio: Todos los proyectos no comerciales registrados para usar Earth Engine antes del
15 de abril de 2025 deben
verificar su elegibilidad no comercial para mantener el acceso a Earth Engine.
ee.Geometry.Polygon
Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
Construye un ee.Geometry que describe un polígono.
Para mayor comodidad, se pueden usar varargs cuando todos los argumentos son números. Esto permite crear polígonos geodésicos EPSG:4326 con un solo LinearRing dado un número par de argumentos, p.ej., ee.Geometry.Polygon(aLng, aLat, bLng, bLat, ..., aLng, aLat).
Uso | Muestra |
---|
ee.Geometry.Polygon(coords, proj, geodesic, maxError, evenOdd) | Geometry.Polygon |
Argumento | Tipo | Detalles |
---|
coords | List<Geometry>|List<List<List<Number>>>|List<Number> | Es una lista de anillos que definen los límites del polígono. Puede ser una lista de coordenadas en el formato "Polygon" de GeoJSON, una lista de objetos ee.Geometry que describen un LinearRing o una lista de números que definen un solo límite de polígono. |
proj | Proyección (opcional) | Es la proyección de esta geometría. El valor predeterminado es la proyección de las entradas, en la que se supone que los números son EPSG:4326. |
geodesic | Booleano, opcional | Si es falso, los bordes son rectos en la proyección. Si es verdadero, los bordes se curvan para seguir la ruta más corta en la superficie de la Tierra. El valor predeterminado es el estado geodésico de las entradas o verdadero si las entradas son números. |
maxError | ErrorMargin, opcional | Es el error máximo cuando la geometría de entrada debe reproyectarse en una proyección de resultado o un estado geodésico solicitados de forma explícita. |
evenOdd | Booleano, opcional | Si es verdadero, los interiores del polígono se determinarán según la regla par/impar, en la que un punto está dentro si cruza una cantidad impar de bordes para alcanzar un punto en el infinito. De lo contrario, los polígonos usan la regla de izquierda-interior, en la que los interiores se encuentran en el lado izquierdo de los bordes de la estructura cuando se recorren los vértices en el orden determinado. Si no se especifica, el valor predeterminado es verdadero. |
Ejemplos
Editor de código (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);
Salvo que se indique lo contrario, el contenido de esta página está sujeto a la licencia Atribución 4.0 de Creative Commons, y los ejemplos de código están sujetos a la licencia Apache 2.0. Para obtener más información, consulta las políticas del sitio de Google Developers. Java es una marca registrada de Oracle o sus afiliados.
Última actualización: 2025-07-25 (UTC)
[null,null,["Última actualización: 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```"]]