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

Teradata® Package for Python User Guide

Product
Teradata Package for Python
Release Number
17.10
Published
May 2022
Language
English (United States)
Last Update
2022-08-18
dita:mapPath
rsu1641592952675.ditamap
dita:ditavalPath
ayr1485454803741.ditaval
dita:id
B700-4006
lifecycle
previous
Product Category
Teradata Vantage

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