Teradata Package for Python Function Reference on VantageCloud Lake | 17.20 - spherical_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
17.20
Publication Date
November 2022
Content Type
Programming Reference
Publication ID
B700-4500-112K
ft:locale
en-US
ft:lastEdition
2024-02-21
ft:sourceId
FTML
dita:id
TeradataPython_FxRef_Lake_1720
Product Category
Teradata Vantage
teradataml.geospatial.geodataframe.GeoDataFrame.spherical_distance = spherical_distance(self, geom_column)
DESCRIPTION:
    Returns the spherical distance between two spherical coordinates on the
    planet using the Haversine Formula. Both coordinates must be specified
    as ST_Point values.
 
PARAMETERS:
    geom_column:
        Required Argument.
        Specifies a Geometry for the other spherical coordinate.
        Types: str, ColumnExpression, GeometryType
 
SUPPORTED GEOMETRY TYPES:
    ST_Point
 
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 and join the GeoDataFrame to self.
    points = geodf.select(["skey", "points"])[geodf.skey.isin([1001, 1002, 1003])]
    points = points.join(points, how="cross", lsuffix="l", rsuffix="r")
 
    # Example 1: Get the spherical distance between two spherical coordinates on the planet using
    #            the Haversine Formula, where coordinates are in columns 'l_point' and 'r_point'.
    points.spherical_distance(points.r_points)
 
    # Example 2: Get the spherical distance between the spherical coordinates on the planet using
    #            the Haversine Formula, where set of points is in column "point" and another geometry
    #            defined by the Point object.
    # Create an object of Point GeometryType.
    p1 = Point(1,3)
    # Pass the Point() GeometryType object as input to "geom_column" argument.
    points.spherical_distance(geom_column=p1)