Constructs an ee.Geometry describing a rectangular polygon. Args: coords: The minimum and maximum corners of the rectangle, as a list of two points each in the format of GeoJSON 'Point' coordinates, or a list of two ee.Geometry objects describing a point, or a list of
(
coords=_UNSPECIFIED,
proj=_UNSPECIFIED,
geodesic=_UNSPECIFIED,
evenOdd=_UNSPECIFIED, # pylint: disable=g-bad-name
*args,
**kwargs,
)
| 237 | # pylint: disable=keyword-arg-before-vararg |
| 238 | @staticmethod |
| 239 | def Rectangle( |
| 240 | coords=_UNSPECIFIED, |
| 241 | proj=_UNSPECIFIED, |
| 242 | geodesic=_UNSPECIFIED, |
| 243 | evenOdd=_UNSPECIFIED, # pylint: disable=g-bad-name |
| 244 | *args, |
| 245 | **kwargs, |
| 246 | ) -> Geometry: |
| 247 | """Constructs an ee.Geometry describing a rectangular polygon. |
| 248 | |
| 249 | Args: |
| 250 | coords: The minimum and maximum corners of the rectangle, as a list of |
| 251 | two points each in the format of GeoJSON 'Point' coordinates, or a |
| 252 | list of two ee.Geometry objects describing a point, or a list of four |
| 253 | numbers in the order xMin, yMin, xMax, yMax. |
| 254 | proj: The projection of this geometry. If unspecified, the default is the |
| 255 | projection of the input ee.Geometry, or EPSG:4326 if there are no |
| 256 | ee.Geometry inputs. |
| 257 | geodesic: If false, edges are straight in the projection. If true, edges |
| 258 | are curved to follow the shortest path on the surface of the Earth. |
| 259 | The default is the geodesic state of the inputs, or true if the |
| 260 | inputs are numbers. |
| 261 | evenOdd: If true, polygon interiors will be determined by the even/odd |
| 262 | rule, where a point is inside if it crosses an odd number of edges to |
| 263 | reach a point at infinity. Otherwise polygons use the left-inside |
| 264 | rule, where interiors are on the left side of the shell's edges when |
| 265 | walking the vertices in the given order. If unspecified, defaults to |
| 266 | True. |
| 267 | *args: For convenience, varargs may be used when all arguments are |
| 268 | numbers. This allows creating EPSG:4326 Polygons given exactly four |
| 269 | coordinates, e.g., |
| 270 | ee.Geometry.Rectangle(minLng, minLat, maxLng, maxLat). |
| 271 | **kwargs: Keyword args that accept "xlo", "ylo", "xhi" and "yhi" for |
| 272 | backward-compatibility. |
| 273 | |
| 274 | Returns: |
| 275 | An ee.Geometry describing a rectangular polygon. |
| 276 | """ |
| 277 | init = Geometry._parseArgs( |
| 278 | 'Rectangle', |
| 279 | 2, |
| 280 | Geometry._GetArgs( |
| 281 | (coords, proj, geodesic, evenOdd) + args, |
| 282 | ('xlo', 'ylo', 'xhi', 'yhi'), |
| 283 | **kwargs, |
| 284 | ), |
| 285 | ) |
| 286 | if not isinstance(init, computedobject.ComputedObject): |
| 287 | # GeoJSON does not have a Rectangle type, so expand to a Polygon. |
| 288 | xy = init['coordinates'] |
| 289 | if not isinstance(xy, (list, tuple)) or len(xy) != 2: |
| 290 | raise ee_exception.EEException( |
| 291 | 'The Geometry.Rectangle constructor requires 2 points or 4 ' |
| 292 | 'coordinates.') |
| 293 | x1 = xy[0][0] |
| 294 | y1 = xy[0][1] |
| 295 | x2 = xy[1][0] |
| 296 | y2 = xy[1][1] |