|
- Method resolution order:
- Polygon
- GeometryType
- builtins.object
Methods defined here:
- __init__(self, coordinates=None)
- DESCRIPTION:
Enables end user to create an object for the single Polygon
using the coordinates. Allows user to use the same in GeoDataFrame
manipulation and processing using any Geospatial function.
PARAMETERS:
coordinates:
Optional Argument.
Specifies the coordinates of a polygon. While passing coordinates
for a polygon, one must always pass coordinates in list of either
two-tuples for 2D or list of three-tuples for 3D.
Argument also accepts list of Point and/or LineString as well
instead of tuples.
If coordinates are not passed, an object for empty polygon is
created.
Types: List of
a. two-tuple of int or float or
b. three-tuple of int or float or
c. Point geometry objects or
d. LineString geometry objects or
e. Mix of any of the above.
RETURNS:
Polygon
RAISES:
TeradataMlException, TypeError, ValueError
EXAMPLES:
>>> from teradataml import Point, LineString, Polygon
# Example 1: Create a Polygon in 2D, using x and y coordinates.
>>> go1 = Polygon([(0, 0), (0, 20), (20, 20), (20, 0), (0, 0)])
>>> # Print the coordinates.
>>> print(go1.coords)
[(0, 0), (0, 20), (20, 20), (20, 0), (0, 0)]
>>> # Print the geometry type.
>>> go1.geom_type
'Polygon'
>>>
# Example 2: Create a Polygon in 3D, using x, y and z coordinates.
>>> go2 = Polygon([(0, 0, 0), (0, 0, 20), (0, 20, 0), (0, 20, 20),
... (20, 0, 0), (20, 0, 20), (20, 20, 0), (20, 20, 20),
... (0, 0, 0)])
>>> # Print the coordinates.
>>> print(go2.coords)
[(0, 0, 0), (0, 0, 20), (0, 20, 0), (0, 20, 20), (20, 0, 0), (20, 0, 20), (20, 20, 0), (20, 20, 20), (0, 0, 0)]
>>>
# Example 3: Create a Polygon using Point geometry objects.
# Create Point objects in 2D, using x and y coordinates.
>>> p1 = Point(0, 0)
>>> p2 = Point(0, 20)
>>> p3 = Point(20, 20)
>>> p4 = Point(20, 0)
>>> go3 = Polygon([p1, p2, p3, p4, p1])
>>> # Print the coordinates.
>>> print(go3.coords)
[(0, 0), (0, 20), (20, 20), (20, 0), (0, 0)]
>>>
# Example 4: Create a Polygon using LineString geometry objects.
# Create some LineString objects in 2D, using x and y coordinates.
>>> l1 = LineString([(0, 0), (0, 20), (20, 20)])
>>> l2 = LineString([(20, 0), (0, 0)])
>>> go4 = Polygon([l1, l2])
>>> # Print the coordinates.
>>> print(go4.coords)
[(0, 0), (0, 20), (20, 20), (20, 0), (0, 0)]
>>>
# Example 5: Create a Polygon using mix of Point, LineString
# geometry objects and coordinates.
>>> p1 = Point(0, 0)
>>> l1 = LineString([p1, (0, 20), (20, 20)])
>>> go5 = Polygon([l1, (20, 0), p1])
>>> # Print the coordinates.
>>> print(go5.coords)
[(0, 0), (0, 20), (20, 20), (20, 0), (0, 0)]
>>>
# Example 6: Create an empty Polygon.
>>> poe = Polygon()
>>> # Print the coordinates.
>>> print(poe.coords)
EMPTY
>>>
Methods inherited from GeometryType:
- __getattr__(self, item)
- __str__(self)
- Return String Representation for a Geometry object.
Readonly properties inherited from GeometryType:
- coords
- Returns the coordinates of the Geometry object.
- geom_type
- Returns the type of a Geometry.
|