Teradata Package for Python Function Reference | 20.00 - geometry - 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
- lifecycle
- latest
- Product Category
- Teradata Vantage
- teradataml.geospatial.geodataframe.GeoDataFrame.geometry
- DESCRIPTION:
Returns a GeoColumnExpression for a column containing geometry data.
If GeoDataFrame contains, multiple columns containing geometry data,
then it returns reference to only one of them.
Columns containing geometry data can be of following types:
1. ST_GEOMETRY
2. MBB
3. MBR
Refer 'GeoDataFrame.tdtypes' to view the Teradata column data types.
Note:
This property is used to execute any geospatial operation on
GeoDataFrame, i.e., any geospatial function executed on
GeoDataFrame, is executed on the geomtry column referenced by
this property.
RETURNS:
GeoDataFrameColumn
EXAMPLES:
>>> load_example_data("geodataframe", ["sample_cities", "sample_streets"])
>>> cities = GeoDataFrame("sample_cities")
>>> streets = GeoDataFrame("sample_streets")
>>> city_streets = cities.join(streets, how="cross", lsuffix="l", rsuffix="r")
>>> city_streets
l_skey r_skey city_name city_shape street_name street_shape
0 0 1 Oceanville POLYGON ((1 1,1 3,6 3,6 0,1 1)) Main Street LINESTRING (2 2,3 2,4 1)
1 0 1 Oceanville POLYGON ((1 1,1 3,6 3,6 0,1 1)) Coast Blvd LINESTRING (12 12,18 17)
2 1 1 Seaside POLYGON ((10 10,10 20,20 20,20 15,10 10)) Coast Blvd LINESTRING (12 12,18 17)
3 1 1 Seaside POLYGON ((10 10,10 20,20 20,20 15,10 10)) Main Street LINESTRING (2 2,3 2,4 1)
>>>
# Check the name of the column containing geometry data, where
# 'geometry' property references.
>>> city_streets.geometry.name
'city_shape'
>>>
# Check all the column types.
>>> city_streets.tdtypes
l_skey INTEGER()
r_skey INTEGER()
city_name VARCHAR(length=40, charset='LATIN')
city_shape GEOMETRY()
street_name VARCHAR(length=40, charset='LATIN')
street_shape GEOMETRY()
>>>
>>>
# Set the 'geometry' property to refer 'street_shape' column.
>>> city_streets.geometry = city_streets.street_shape
>>> city_streets.geometry.name
'street_shape'
>>>
# Check whether the geometry referenced by 'geometry' property are 3D
# or not.
>>> city_streets.is_3D
l_skey r_skey city_name city_shape street_name street_shape is_3D_street_shape_geom
0 1 1 Seaside POLYGON ((10 10,10 20,20 20,20 15,10 10)) Main Street LINESTRING (2 2,3 2,4 1) 0
1 1 1 Seaside POLYGON ((10 10,10 20,20 20,20 15,10 10)) Coast Blvd LINESTRING (12 12,18 17) 0
2 0 1 Oceanville POLYGON ((1 1,1 3,6 3,6 0,1 1)) Coast Blvd LINESTRING (12 12,18 17) 0
3 0 1 Oceanville POLYGON ((1 1,1 3,6 3,6 0,1 1)) Main Street LINESTRING (2 2,3 2,4 1) 0
>>>
# Use the geometry property to execute multiple geospatial functions
# in conjunctions with GeoDataFrame.assign()
# Get the geometry type.
>>> geom_type = city_streets.geometry.geom_type
# Check if geometry is simple or not.
>>> is_simple = city_streets.geometry.is_simple
# Check if geometry is valid or not.
>>> is_valid = city_streets.geometry.is_valid
>>>
# Call GeoDataFrame.assign() and pass the above GeoDataFrameColumn, i.e.,
# ColumnExpressions as input.
>>> city_streets.assign(geom_type = geom_type,
... is_simple = is_simple,
... is_valid = is_valid
... )
l_skey r_skey city_name city_shape street_name street_shape geom_type is_simple is_valid
0 0 1 Oceanville POLYGON ((1 1,1 3,6 3,6 0,1 1)) Main Street LINESTRING (2 2,3 2,4 1) ST_LineString 1 1
1 0 1 Oceanville POLYGON ((1 1,1 3,6 3,6 0,1 1)) Coast Blvd LINESTRING (12 12,18 17) ST_LineString 1 1
2 1 1 Seaside POLYGON ((10 10,10 20,20 20,20 15,10 10)) Coast Blvd LINESTRING (12 12,18 17) ST_LineString 1 1
3 1 1 Seaside POLYGON ((10 10,10 20,20 20,20 15,10 10)) Main Street LINESTRING (2 2,3 2,4 1) ST_LineString 1 1
>>>