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

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
Language
English (United States)
Last Update
2024-04-03
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

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