Teradata Package for Python Function Reference | 17.10 - contains - 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

Product
Teradata Package for Python
Release Number
17.10
Published
April 2022
Language
English (United States)
Last Update
2022-08-19
lifecycle
previous
Product Category
Teradata Vantage
teradataml.geospatial.geodataframecolumn.GeoDataFrameColumn.contains = contains(self, geom_column)
DESCRIPTION:
    Tests if a Geometry value spatially contains another Geometry value.
    Note:
        *  Using a geospatial index can greatly improve the performance of
          queries that use this method.
 
PARAMETERS:
    geom_column:
        Required Argument.
        Specifies the other Geometry value.
        Types: str, ColumnExpression, GeometryType
 
SUPPORTED GEOMETRY TYPES:
    All Geometry types except geometry collections.
    Note:
        This method can be called on 3D geometries (those that include Z
        coordinates). However, the Z coordinate is ignored in method
        calculations.
 
RAISES:
    TypeError, ValueError, TeradataMlException
 
RETURNS:
    GeoDataFrameColumn
    Resultant column contains:
        * 1, if the input geometry contains other geometry
        * 0, if the input geometry does not contain other geometry
 
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: Check if the ST_Linestring/ST_MultiLinestring type geometries in column
    #            'linestrings' contains the geometries in column 'points' of type ST_Point/ST_MultiPoint.
    # Pass the GeoDataFrameColumnColumn object of 'points' columns as input to "geom_column" argument.
    contains_expr = points_lines.linestrings.contains(geom_column=points_lines.points)
    points_lines.assign(res = contains_expr)
 
    # Example 2: Check if the ST_Linestring/ST_MultiLinestring type geometries in column
    #            'linestrings' contains the geometry specified by a GeometryType object - Point.
    # Create a Point GeometryType object with co-ordinates 1 and 3.
    point1 = Point(1, 3)
    # Pass the Point() GeometryType object as input to "geom_column" argument.
    contains_expr = points_lines.points.contains(geom_column=point1)
    points_lines.assign(res = contains_expr)
 
    # Example 3: Filter rows if the ST_Linestring/ST_MultiLinestring type geometries in column
    #            'linestrings' contains the geometries in column 'points' of type ST_Point/ST_MultiPoint.
    # Pass the GeoDataFrameColumnColumn object of 'points' columns as input to "geom_column" argument.
    contains_expr = points_lines.linestrings.contains(geom_column=points_lines.points)
    points_lines[contains_expr == 1]