snowflake.snowpark.functions.st_pointn¶
- snowflake.snowpark.functions.st_pointn(geography_or_geometry_expression: Union[snowflake.snowpark.column.Column, str], index: Union[snowflake.snowpark.column.Column, str]) Column[source] (https://github.com/snowflakedb/snowpark-python/blob/v1.41.0/src/snowflake/snowpark/_functions/scalar_functions.py#L3153-L3184)¶
Returns the Nth point in a LINESTRING. Points are indexed starting from 1. Negative values are counted backwards from the end of the LINESTRING, where -1 is the last point.
- Parameters:
geography_or_geometry_expression (ColumnOrName) – LINESTRING values in GEOGRAPHY or GEOMETRY format
index (ColumnOrName) – The 1-based index of the point to return. Negative values count from the end
- Returns:
The Nth point as a POINT object
- Return type:
- Examples::
>>> from snowflake.snowpark.functions import to_geography, to_geometry, lit >>> df = session.create_dataframe([["LINESTRING(1 1, 2 2, 3 3, 4 4)"]], schema=["linestring"]) >>> df.select(st_pointn(to_geography(df["linestring"]), lit(2)).alias("point")).collect() [Row(POINT='{\n "coordinates": [\n 2.000000000000000e+00,\n 2.000000000000000e+00\n ],\n "type": "Point"\n}')] >>> df.select(st_pointn(to_geometry(df["linestring"]), lit(-2)).alias("point")).collect() [Row(POINT='{\n "coordinates": [\n 3.000000000000000e+00,\n 3.000000000000000e+00\n ],\n "type": "Point"\n}')]