Teradata Package for Python Function Reference | 20.00 - geom_component - Teradata Package for Python - Look here for syntax, methods and examples for the functions included in the Teradata Package for Python.

Teradata® Package for Python Function Reference - 20.00

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Teradata Package for Python
Release Number
20.00
Published
March 2024
Language
English (United States)
Last Update
2024-04-10
dita:id
TeradataPython_FxRef_Enterprise_2000
Product Category
Teradata Vantage
teradataml.geospatial.geodataframecolumn.GeoDataFrameColumn.geom_component = geom_component(self, position)
DESCRIPTION:
    Returns the geometry of one component member of a composite geometry
    type (ST_GeomCollection, ST_MultiPoint, ST_MultiLineString, or
    ST_MultiPolygon). The element to be returned is specified by position
    with the collection.
 
PARAMETERS:
    position:
        Required Argument.
        Specifies a value representing the position in the collection of the
        geometry to be returned. The position of the first element in the
        collection is number 1.
        Types: int, str, ColumnExpression
 
SUPPORTED GEOMETRY TYPES:
    ST_GeomCollection, ST_MultiPoint, ST_MultiLineString, and ST_MultiPolygon
 
RAISES:
    TypeError, ValueError, TeradataMlException
 
RETURNS:
    GeoDataFrameColumn containing Geometry values
 
EXAMPLES:
    from teradataml import GeoDataFrame, load_example_data
    from teradataml import Point, LineString, Polygon, GeometryCollection
    # Load example data.
    load_example_data("geodataframe", "sample_shapes")
    # Create a GeoDataFrame.
    geodf = GeoDataFrame("sample_shapes")
    print(geodf)
 
    # Example 1: Get the geometry component at position 1 in ST_GeometryCollection, a composite geometry type,
    #            geometries in column 'geom_collections'.
    geom_collections = geodf.select(["skey", "geom_collections"])
    ep_expr = geom_collections.geometry.geom_component(position=1)
    geom_collections.assign(res = ep_expr)
 
    # Example 2: Filter the rows where the geometry component at position 1 in ST_GeometryCollection,
    #            a composite geometry type, geometries in column 'geom_collections' is same as the
    #            specified Point GeometryType object.
    # Create an object of Point GeometryType.
    p1 = Point(10, 20, 30)
    # Execute the geom_component() function on 'geom_collections' column.
    ep_expr = geom_collections.geometry.geom_component(position=1)
    geom_collections[ep_expr == p1]