ST_LineInterpolatePoint takes a linestring column and a number between 0 and 1 and returns a point column. The output column represents the location along the input linestring at the fractional distance specified, where 0 returns the first point in the line and 1 returns the last point in the line. This function always returns null for multipart linestrings and other geometries. This function uses planar distance calculations.

FunctionSyntax
Pythonline_interpolate_point(linestring, fraction)
SQLST_LineInterpolatePoint(linestring, fraction)
ScalalineInterpolatePoint(linestring, fraction)

For more details, go to the GeoAnalytics for Microsoft Fabric API reference for line_interpolate_point.

Python and SQL Examples

PythonPythonSQL
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

from geoanalytics_fabric.sql import functions as ST

data = [
    ("LINESTRING (-117.27 34.05, -117.22 33.91, -116.96 33.64)",),
    ("LINESTRING (-116.89 33.96, -116.71 34.01, -116.66 34.08)",),
    ("LINESTRING (-116.24 33.88, -116.33 34.02)",)
]

df = spark.createDataFrame(data, ["line_wkt",]) \
          .withColumn("linestring", ST.line_from_text("line_wkt", sr=4326)) \
          .withColumn("line_interpolate_point", ST.line_interpolate_point("linestring", 0.25))

ax = df.st.plot("linestring", edgecolor="lightgrey", zorder=0, linewidths=10, figsize=(15, 8))
df.st.plot("line_interpolate_point", ax=ax, facecolor="red", s=75, zorder=1)
ax.legend(['Input linestring','Point 25% along linestring'], loc='lower right', fontsize='x-large');

Plotting example for ST_LineInterpolatePoint

Plotted result for ST_LineInterpolatePoint.

Scala Example

Scala
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

import com.esri.geoanalytics.sql.{functions => ST}
import org.apache.spark.sql.{functions => F}

case class lineRow(lineWkt: String)

val data = Seq(lineRow("LINESTRING (-117.27 34.05, -117.22 33.91, -116.96 33.64)"),
               lineRow("LINESTRING (-116.89 33.96, -116.71 34.01, -116.66 34.08)"),
               lineRow("LINESTRING (-116.24 33.88, -116.33 34.02)"))

val df = spark.createDataFrame(data)
              .withColumn("linestring", ST.lineFromText($"lineWkt", F.lit(4326)))
              .withColumn("line_interpolate_point", ST.lineInterpolatePoint($"linestring", F.lit(0.25)))

df.select("line_interpolate_point").show(truncate = false)
Result
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
+------------------------------------------------+
|line_interpolate_point                          |
+------------------------------------------------+
|{"x":-117.22598247991357,"y":33.92675094375801} |
|{"x":-116.82427876385185,"y":33.97825589893004} |
|{"x":-116.26249999999999,"y":33.915000000000006}|
+------------------------------------------------+

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.