Teradata Package for Python Function Reference on VantageCloud Lake | 17.20 - intersection - 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 on VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Package for Python
Release Number
17.20
Publication Date
November 2022
Content Type
Programming Reference
Publication ID
B700-4500-112K
ft:locale
en-US
ft:lastEdition
2024-02-21
ft:sourceId
FTML
dita:id
TeradataPython_FxRef_Lake_1720
Product Category
Teradata Vantage
teradataml.geospatial.geodataframecolumn.GeoDataFrameColumn.intersection = intersection(self, geom_column)
DESCRIPTION:
    Returns a Geometry type where the value represents the point set
    intersection of two Geometry values.
 
PARAMETERS:
    geom_column:
        Required Argument.
        Specifies the other Geometry value.
        Types: str, ColumnExpression, GeometryType
 
SUPPORTED GEOMETRY TYPES:
    All Geometry types, including GeoSequence, but not the ST_GeomCollection type.
    Note:
        This method can be called on 3D geometries (those that include Z
        coordinates). However, the Z coordinate is ignored in method
        calculations. Consequently, any Z coordinates returned by this
        method should be ignored. Teradata recommends using the make_2D()
        method to strip out the Z coordinates of the return value.
 
RAISES:
    TypeError, ValueError, TeradataMlException
 
RETURNS:
    GeoDataFrameColumn
    Notes:
        Returns a Geometry type where the representation is one of the
        possible set of types in the following table, depending on the
        parameter types.
        +==============+=====+=====+==============+======+======+=======+=======+
        | a n b        | Ø   | Pnt | Line, GeoSeq | Poly | MPnt | MLine | MPoly |
        +==============+=====+=====+==============+======+======+=======+=======+
        | Ø            | Ø   | Ø   | Ø            | Ø    | Ø    | Ø     | Ø     |
        +--------------+-----+-----+--------------+------+------+-------+-------+
        | Pnt          | Ø   | R09 | R09          | R09  | R09  | R09   | R09   |
        +--------------+-----+-----+--------------+------+------+-------+-------+
        | Line, GeoSeq | Ø   | R09 | R11          | R11  | R13  | R11   | R11   |
        +--------------+-----+-----+--------------+------+------+-------+-------+
        | Poly         | Ø   | R09 | R11          | R12  | R13  | R11   | R12   |
        +--------------+-----+-----+--------------+------+------+-------+-------+
        | MPnt         | Ø   | R09 | R13          | R13  | R13  | R13   | R13   |
        +--------------+-----+-----+--------------+------+------+-------+-------+
        | MLine        | Ø   | R09 | R11          | R11  | R13  | R11   | R11   |
        +--------------+-----+-----+--------------+------+------+-------+-------+
        | MPoly        | Ø   | R09 | R11          | R12  | R13  | R11   | R12   |
        +--------------+-----+-----+--------------+------+------+-------+-------+
        Where:
            Pnt     = ST_Point
            Line    = ST_LineString
            Poly    = ST_Polygon
            MPnt    = ST_MultiPoint
            MLine   = ST_MultiLineString
            MPoly   = ST_MultiPolygon
            GeoSeq  = GeoSequence
            R09     = Ø, ST_Point
            R11     = Ø, ST_Point, ST_LineString, ST_MultiPoint, ST_MultiLineString
            R12     = Ø, ST_Point, ST_LineString, ST_Polygon, ST_MultiPoint,
                      ST_MultiLineString, ST_MultiPolygon
            R13     = Ø, ST_Point, ST_MultiPoint
        Vantage converts GeoSequence types that are involved in the intersection()
        method to ST_LineString values. Therefore, intersection() never returns a
        GeoSequence type.
 
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)
 
    # Let's select only few columns from GeoDataFrame.
    points_lines = geodf.select(["skey", "points", "linestrings"])
 
    # Example 1: Get the point set interection geometry value between the geometries in columns
    #            'points' and 'linestrings'.
    geo_ints1 = points_lines.geometry.intersection(geom_column=points_lines.linestrings)
    points_lines.assign(res = geo_ints1)
 
    # Example 2: Get the point set interection geometry value between the geometries in column
    #            'linestrings' and geometry type specified by Linestring.
    # Create an object of Linestring GeometryType.
    l1 = LineString([(1,3), (3,0), (0,1)])
    # Pass the LineString() GeometryType object as input to "geom_column" argument.
    geo_ints2 = points_lines.linestrings.intersection(geom_column=l1)
    points_lines.assign(res = geo_ints2)
 
    # Example 3: Filter the rows where the point set interection geometry value between the geometries
    #            in columns 'points' and 'linestrings' is same as the Empty GeometryCollection object.
    # Create an object of GeometryCollection GeometryType.
    gc1 = GeometryCollection()
    # Execute intersection() function on 'points' and 'linestrings' columns.
    geo_ints1 = points_lines.points.intersection(geom_column=points_lines.linestrings)
    points_lines[geo_ints1 == gc1]