GeometryCollection | Geospatial Types | Teradata Package for Python - GeometryCollection - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
Language
English (United States)
Last Update
2024-04-03
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

This function enables end user to create an object holding the multiple types of geometry objects. It allows user to use the same in GeoDataFrame manipulation and processing using any Geospatial function.

Optional argument:

geoms: Specifies a list of different types of geometry objects.
  • If no geometry objects are passed, an object for empty GeometryCollection is created.
  • When geometry objects are passed, you must pass a list of the following types:
    • Point;
    • LineString;
    • Polygon;
    • MultiPoint;
    • MultiLineString;
    • MultiPolygon;
    • GeometryCollection;
    • Mix of any of these seven types.

Example 1: Create a GeometryCollection object with all geometry types

>>> from teradataml import Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, GeometryCollection
>>> # 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, po3, 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