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.geodataframecolumn.GeoDataFrameColumn.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:
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 - 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, 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 difference between ST_Linestring/ST_MultiLinestring geometries in column
# 'linestrings' and ST_Point/ST_MultiPoint geometries in column 'points'.
_expr = points_lines.linestrings.difference(geom_column=points_lines.points)
points_lines.assign(res = _expr)
# 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.
_expr = points_lines.linestrings.difference(geom_column=l1)
points_lines.assign(res = _expr)
# Example 3: Filter the rows where the difference between ST_Linestring/ST_MultiLinestring
# geometries in column 'linestrings' and ST_Point/ST_MultiPoint geometries in
# column 'points' is same as specific LineString GeometryType object.
# Create an object of LineString GeometryType.
l1 = LineString([(1, 3, 6), (3, 0, 6), (6, 0, 1)])
_expr = points_lines.linestrings.difference(geom_column=points_lines.points)
points_lines[(_expr == l1)]