|
- Method resolution order:
- GeometryCollection
- GeometryType
- builtins.object
Methods defined here:
- __init__(self, geometries=None)
- DESCRIPTION:
Enables end user to create an object holding the multiple types of
geometry objects. Allows user to use the same in GeoDataFrame
manipulation and processing using any Geospatial function.
PARAMETERS:
geoms:
Optional Argument.
Specifies the list of different geometry types.
If no geometries are are passed, an object for empty
GeometryCollection is created.
Types: List of geometry objects of types:
1. Point
2. LineString
3. Polygon
4. MultiPoint
5. MultiLineString
6. MultiPolygon
7. GeometryCollection
8. Mixture of any of these.
RETURNS:
GeometryCollection
RAISES:
TeradataMlException, TypeError, ValueError
EXAMPLES:
>>> from teradataml import Point, LineString, Polygon, MultiPoint,
... MultiLineString, MultiPolygon, GeometryCollection
# Example 1: Create a MultiPoint in 2D, using x and y coordinates.
>>> # Create Point objects.
>>> p1 = Point(1, 1)
>>> p2 = Point()
>>> p3 = Point(6, 3)
>>> p4 = Point(10, 5)
>>> p5 = Point()
>>>
>>> # Create LineString Objects.
>>> l1 = LineString([(1, 3), (3, 0), (0, 1)])
>>> l2 = LineString([(1.35, 3.6456), (3.6756, 0.23), (0.345, 1.756)])
>>> l3 = LineString()
>>>
>>> # Create Polygon Objects.
>>> po1 = 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)])
>>> po2 = Polygon([(0, 0, 0), (0, 0, 20.435), (0, 20.435, 0),
... (0, 20.435, 20.435), (20.435, 0, 0), (20.435, 0, 20.435),
... (20.435, 20.435, 0), (20.435, 20.435, 20.435),
... (0, 0, 0)])
>>> po3 = Polygon()
>>>
>>> # Create MultiPolygon Object.
>>> mpol = MultiPolygon([po1, Polygon(), po2])
>>>
>>> # Create MultiLineString Object.
>>> mlin = MultiLineString([l1, l2, l3])
>>>
>>> # Create MultiPoint Object.
>>> mpnt = MultiPoint([p1, p2, p3, p4, p5])
>>>
>>> # Create a GeometryCollection object.
>>> gc1 = GeometryCollection([p1, p2, l1, l3, po2, po3, po1, mpol, mlin, mpnt])
>>> # Print the coordinates.
>>> print(gc1.coords)
[(1, 1), 'EMPTY', [(1, 3), (3, 0), (0, 1)], 'EMPTY', [(0, 0, 0), (0, 0, 20.435), (0, 20.435, 0), (0, 20.435, 20.435), (20.435, 0, 0), (20.435, 0, 20.435), (20.435, 20.435, 0), (20.435, 20.435, 20.435), (0, 0, 0)], 'EMPTY', [(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)], [[(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)], 'EMPTY', [(0, 0, 0), (0, 0, 20.435), (0, 20.435, 0), (0, 20.435, 20.435), (20.435, 0, 0), (20.435, 0, 20.435), (20.435, 20.435, 0), (20.435, 20.435, 20.435), (0, 0, 0)]], [[(1, 3), (3, 0), (0, 1)], [(1.35, 3.6456), (3.6756, 0.23), (0.345, 1.756)], 'EMPTY'], [(1, 1), 'EMPTY', (6, 3), (10, 5), 'EMPTY']]
>>> # Print the geometry type.
>>> print(gc1.geom_type)
GeometryCollection
>>>
# Example 2: Create an empty GeometryCollection.
>>> gc2 = GeometryCollection()
>>> # Print the coordinates.
>>> print(gc2.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.
|