LineString | Geospatial Types | Teradata Package for Python - LineString - Teradata Package for Python

Teradata® Package for Python User Guide

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Teradata Package for Python
Release Number
20.00
Published
December 2024
ft:locale
en-US
ft:lastEdition
2025-01-23
dita:mapPath
nvi1706202040305.ditamap
dita:ditavalPath
plt1683835213376.ditaval
dita:id
rkb1531260709148
lifecycle
latest
Product Category
Teradata Vantage

This function enables end user to create an object for the single LineString using the coordinates. It allows user to use the same in GeoDataFrame manipulation and processing using any Geospatial function.

Optional argument:

coordinates: Specifies the coordinates of a line.
  • If coordinates are not passed, an object for empty line is created.
  • When coordinates are passed, you must pass a list of the following types:
    • Two-tuple of int or float;
    • Three-tuple of int or float;
    • Point geometry objects;
    • Mix of any of these three types.

Example 1: Create a LineString in 2D, using x and y coordinates

>>> from teradataml import Point, LineString
>>> l1 = LineString([(0, 0), (0, 20), (20, 20)])
>>> # Print the coordinates.
>>> print(l1.coords)
[(0, 0), (0, 20), (20, 20)]
>>> # Print the geometry type.
>>> l1.geom_type
'LineString'

Example 2: Create a LineString in 3D, using x, y and z coordinates

>>> from teradataml import Point, LineString
>>> l2 = LineString([(0, 0, 1), (0, 1, 3), (1, 3, 6), (3, 3, 6), (3, 6, 1), (6, 3, 3), (3, 3, 0)])
>>> # Print the coordinates.
>>> print(l2.coords)
[(0, 0, 1), (0, 1, 3), (1, 3, 6), (3, 3, 6), (3, 6, 1), (6, 3, 3), (3, 3, 0)]

Example 3: Create a LineString using Point geometry objects

>>> from teradataml import Point, LineString
# Create some Points in 2D, using x and y coordinates.
>>> p1 = Point(0, 20)
>>> p2 = Point(0, 0)
>>> p3 = Point(20, 20)
>>> l3 = LineString([p1, p2, p3])
>>> # Print the coordinates.
>>> print(l3.coords)
[(0, 20), (0, 0), (20, 20)]

Example 4: Create a LineString using mix of Point geometry objects and coordinates

>>> from teradataml import Point, LineString
>>> p1 = Point(0, 20)
>>> p2 = Point(20, 20)
>>> l4 = LineString([(0, 0), p1, p2, (20, 0)])
>>> # Print the coordinates.
>>> print(l4.coords)
[(0, 0), (0, 20), (20, 20), (20, 0)]

Example 5: Create an empty LineString

>>> from teradataml import Point, LineString
>>> le = LineString()
>>> # Print the coordinates.
>>> print(le.coords)
EMPTY