Teradata Package for Python Function Reference on VantageCloud Lake - distance - 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 on VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
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_Lake_2000
Product Category
Teradata Vantage
teradataml.geospatial.geodataframe.GeoDataFrame.distance = distance(self, geom_column)
DESCRIPTION:
    Returns the distance between two Geometry values.
    Notes:
        *  distance() returns NULL if the geometry value passed to it is the
          empty set.
        *  Both geometries must use the same spatial reference system (have the
          same SRS ID).
        *  If a geospatial index is defined on the geospatial data column to
          which this method is applied, the index will not be used. If user wants
          index to be applied, then use the method on GeoDataFrame column with
          slice filtering such that the distance between the geometries is
          less than or equal to a constant.
 
PARAMETERS:
    geom_column:
        Required Argument.
        Specifies the other Geometry value.
        Types: str, ColumnExpression, GeometryType
 
SUPPORTED GEOMETRY TYPES:
    All Geometry types.
 
RAISES:
    TypeError, ValueError, TeradataMlException
 
RETURNS:
    GeoDataFrame
 
EXAMPLES:
    from teradataml import GeoDataFrame, load_example_data
    from teradataml import Point, LineString, Polygon
    # 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: Calculate the distance between (ST_Linestring/ST_MultiLinestring) geometries in column
    #            'linestrings' and (ST_Point/ST_MultiPoint) geometries in column 'points'.
    points_lines.distance(geom_column=points_lines.linestrings)
 
    # Example 2: Calculate the distance between (ST_Linestring/ST_MultiLinestring) geometries in column
    #            'linestrings' and the geometry specified by a GeometryType object - Point.
    # Create an object of Point GeometryType.
    p1 = Point(3, 1)
    # Pass the Point() GeometryType object as input to "geom_column" argument.
    points_lines.distance(geom_column=p1)