Teradata Package for Python Function Reference | 20.00 - make_2D - 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 - 20.00
- Deployment
- VantageCloud
- VantageCore
- Edition
- Enterprise
- IntelliFlex
- VMware
- Product
- Teradata Package for Python
- Release Number
- 20.00.00.03
- Published
- December 2024
- ft:locale
- en-US
- ft:lastEdition
- 2024-12-19
- dita:id
- TeradataPython_FxRef_Enterprise_2000
- Product Category
- Teradata Vantage
- teradataml.geospatial.geodataframecolumn.GeoDataFrameColumn.make_2D = make_2D(self, validate=False)
- DESCRIPTION:
Converts a 3D Geometry value to a 2D Geometry value, and optionally
validates that the 2D geometry is well-formed. This method strips the z
coordinate from 3D geometries.
Notes:
* The is_valid method can be used to validate converted 2D
geometries that were not validated by make_2D().
* If the input geometry is already a 2D geometry value, this value is
returned unchanged by this method.
* A well-formed 3D geometry value can become invalid during a 3D to 2D
conversion. For example, if a 3D polygon lies in a plane parallel to
the y axis, its line segments will self-intersect. make_2D() does not
attempt to change the geometry type of the converted geometry from
polygon to linestring to account for this, and an invalid 2D
geometry can result.
PARAMETERS:
validate:
Optional Argument.
Specifies a value that determines whether the converted 2D geometry
is tested to ensure it is well-formed. When "validate" is set to True,
the 2D geometry is tested. If it is not well-formed, Vantage
returns an error. If validate is set to False or is not specified,
the 2D geometry is not tested.
Default Value: False
Types: bool, str, ColumnExpression
SUPPORTED GEOMETRY TYPES:
All Geometry types.
RAISES:
TypeError, ValueError, TeradataMlException
RETURNS:
GeoDataFrameColumn
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)
# Example 1: Convert 3D ST_Point/ST_MultiPoint geometries in column 'points' to 2D.
# Let's select only few columns from GeoDataFrame and get only rows which contains 3D geometries.
points_df = geodf.select(["skey", "points"])[geodf.points.is_3D == 1]
points_df.assign(res = points_df.geometry.make_2D())
# Example 2: Filter rows where converted 3D ST_Point/ST_MultiPoint geometries in column 'points' to 2D
# is same as the specified Point GeometryType object.
# Create an object of Point GeometryType.
p1 = Point(1, 3)
points_df[points_df.geometry.make_2D() == p1]