Teradata Package for Python Function Reference | 17.10 - distance_3D - 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

Product
Teradata Package for Python
Release Number
17.10
Published
April 2022
Language
English (United States)
Last Update
2022-08-19
lifecycle
previous
Product Category
Teradata Vantage
teradataml.geospatial.geodataframe.GeoDataFrame.distance_3D = distance_3D(self, geom_column)
DESCRIPTION:
    Returns the distance between two Geometry values. Function
    considers Z coordinate values, if they exist in the geometries passed to
    it.
    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:
    ST_Point, ST_MultiPoint, ST_LineString, and ST_MultiLineString
    To be valid with distance_3D, these shapes must include Z coordinates.
 
RAISES:
    TypeError, ValueError, TeradataMlException
 
RETURNS:
    GeoDataFrame
    Resultant column contains:
        * a NULL, if the Geometry is an empty set.
        * 0, if the two geometries intersect.
        * a float in all other cases. The distance units are those of
          the two input geometries.
 
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)
    
    # Function works with only 3D geometries, hence let's select only few columns from GeoDataFrame
    # and filter the rows which contains 3D geometries.
    points_lines = geodf.select(["skey", "points", "linestrings"])[geodf.points.is_3D == 1]
 
    # Example 1: Calculate the distance between 3D geometries in column 'linestrings' and 3D
    #            geometries in column 'points'.
    points_lines.distance_3D(geom_column=points_lines.linestrings)
 
    # Example 2: Calculate the distance between 3D geometries in column 'linestrings' and 3D Point
    #            GeometryType object.
    # Create a 3D Point GeometryType object.
    p1 = Point(3, 1, 0)
    # Pass the Point() GeometryType object as input to "geom_column" argument.
    points_lines.distance_3D(geom_column=p1)