Teradata Package for Python Function Reference | 17.10 - difference - 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.geodataframe.GeoDataFrame.difference = difference(self, geom_column)
DESCRIPTION:
    Returns a Geometry value that represents the point set difference of
    two Geometry values.
 
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. 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:
    GeoDataFrame
    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 - b        | Ø   | Pnt | Line, GeoSeq | Poly | MPnt | MLine | MPoly |
        +==============+=====+=====+==============+======+======+=======+=======+
        | Ø            | Ø   | Ø   | Ø            | Ø    | Ø    | Ø     | Ø     |
        +--------------+-----+-----+--------------+------+------+-------+-------+
        | Pnt          | R01 | R09 | R09          | R09  | R09  | R09   | R09   |
        +--------------+-----+-----+--------------+------+------+-------+-------+
        | Line, GeoSeq | R02 | R02 | R08          | R08  | R02  | R08   | R08   |
        +--------------+-----+-----+--------------+------+------+-------+-------+
        | Poly         | R03 | R03 | R03          | R14  | R14  | R14   | R14   |
        +--------------+-----+-----+--------------+------+------+-------+-------+
        | MPnt         | R04 | R13 | R13          | R13  | R13  | R13   | R13   |
        +--------------+-----+-----+--------------+------+------+-------+-------+
        | MLine        | R05 | R05 | R08          | R08  | R05  | R08   | R08   |
        +--------------+-----+-----+--------------+------+------+-------+-------+
        | MPoly        | R06 | R06 | R06          | R14  | R06  | R05   | R06   |
        +--------------+-----+-----+--------------+------+------+-------+-------+
        Where:
            Pnt, R01   = ST_Point
            Line, R02  = ST_LineString
            Poly, R03  = ST_Polygon
            MPnt, R04  = ST_MultiPoint
            MLine, R05 = ST_MultiLineString
            MPoly, R06 = ST_MultiPolygon
            GeoSeq     = GeoSequence
            R08        = Ø, ST_LineString, ST_MultiLineString
            R09        = Ø, ST_Point
            R13        = Ø, ST_Point, ST_MultiPoint
            R14        = Ø, ST_Polygon, ST_MultiPolygon
        Vantage converts GeoSequence types that are involved in the difference()
        method to ST_LineString values. Therefore, difference() never returns a GeoSequence
        type.
 
EXAMPLES:
    from teradataml import GeoDataFrame, load_example_data
    from teradataml import Point, LineString, Polygon
    # 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 difference between ST_Linestring/ST_MultiLinestring geometries in column
    #            'linestrings' and ST_Point/ST_MultiPoint geometries in column 'points'.
    # Set the geometry property of GeoDataFrame to point to 'linestrings' column.
    points_lines.geometry = points_lines.linestrings
    points_lines.difference(geom_column=points_lines.points)
 
    # Example 2: Get the difference between ST_Linestring/ST_MultiLinestring geometries in column
    #            'linestrings' and the geometry specified by a GeometryType object - LineString.
    # Create an object of Linestring GeometryType.
    l1 = LineString([(3, 1), (0,2)])
    # Pass the LineString() GeometryType object as input to "geom_column" argument.
    points_lines.difference(geom_column=l1)