Teradata Package for Python Function Reference on VantageCloud Lake | 17.20 - sym_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 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.geodataframe.GeoDataFrame.sym_difference = sym_difference(self, geom_column)
DESCRIPTION:
    Returns a Geometry value that represents the point set symmetric
    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.
        +==============+=====+=====+==============+======+======+=======+=======+
        | u (a - b)    | Ø   | Pnt | Line, GeoSeq | Poly | MPnt | MLine | MPoly |
        +==============+=====+=====+==============+======+======+=======+=======+
        | Ø            | Ø   | R01 | R02          | R03  | R04  | R05   | R06   |
        +--------------+-----+-----+--------------+------+------+-------+-------+
        | Pnt          | R01 | R10 | R15          | R22  | R10  | R17   | R19   |
        +--------------+-----+-----+--------------+------+------+-------+-------+
        | Line, GeoSeq | R02 | R15 | R08          | R21  | R15  | R08   | R18   |
        +--------------+-----+-----+--------------+------+------+-------+-------+
        | Poly         | R03 | R22 | R21          | R14  | R22  | R21   | R14   |
        +--------------+-----+-----+--------------+------+------+-------+-------+
        | MPnt         | R04 | R10 | R15          | R22  | R10  | R17   | R19   |
        +--------------+-----+-----+--------------+------+------+-------+-------+
        | MLine        | R05 | R17 | R08          | R21  | R17  | R08   | R18   |
        +--------------+-----+-----+--------------+------+------+-------+-------+
        | MPoly        | R06 | R19 | R18          | R14  | R19  | R18   | R14   |
        +--------------+-----+-----+--------------+------+------+-------+-------+
        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
            R10         = Ø, ST_MultiPoint
            R14         = Ø, ST_Polygon, ST_MultiPolygon
            R15         = ST_LineString,
                          ST_GeomCollection of ST_Point and ST_LineString values
            R17         = ST_MultiLineString,
                          ST_GeomCollection of ST_Point and ST_LineString values
            R18         = ST_MultiPolygon,
                          ST_GeomCollection of ST_LineString and ST_Polygon values
            R19         = ST_MultiPolygon,
                          ST_GeomCollection of ST_Point and ST_Polygon values
            R21         = ST_Polygon,
                          ST_GeomCollection of ST_LineString and ST_Polygon values
            R22         = ST_Polygon,
                          ST_GeomCollection of ST_Point and ST_Polygon values
        Vantage converts GeoSequence types that are involved in the sym_difference()
        method to ST_LineString values. Therefore, sym_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 point set symmetric difference between geometries in columns
    #            'points' and 'linestrings'.
    points_lines.sym_difference(geom_column=points_lines.linestrings)
 
    # Example 2: Get the point set symmetric difference between geometries in columns
    #            'linestrings' and a GeometryType object - Linestring.
    # Set the geometry property of GeoDataFrame to point to 'linestrings' column.
    points_lines.geometry = points_lines.linestrings
    # 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.
    points_lines.sym_difference(l1)