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

Product
Release Number
17.10
Published
April 2022
Language
English (United States)
Last Update
2022-08-19
lifecycle
previous
Product Category
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:

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.
+==============+=====+=====+==============+======+======+=======+=======+
| 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 Point, LineString, Polygon, GeometryCollection
# 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.assign(res = points_lines.points.intersection(geom_column=points_lines.linestrings))

# Example 2: Get the point set symmetric difference between geometries in columns
#            'linestrings' and a GeometryType object - 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.
points_lines.assign(res = points_lines.linestrings.intersection(l1))

# Example 3: Filter the rows where the point set symmetric difference between geometries in columns
#            'points' and 'linestrings' is same as the empty GeometryCollection.
# Create an object of empty GeometryCollection GeometryType.
gc1 = GeometryCollection()
points_lines[points_lines.points.intersection(geom_column=points_lines.linestrings) == gc1]