Interpolate geo point along linestring

Supported in: Batch, Streaming

Returns a point interpolated along a line. Implementation interprets lines as the shortest path, using a spherical approximation of the globe.

Expression categories: Geospatial

Declared arguments

  • Fraction - Fraction of the total length of the linestring at which to pull a geo point, starting from the beginning of the linestring. Must be a float between 0 and 1.
    Expression<Decimal | Double | Float>
  • Linestring - Linestring along which to interpolate a geo point.
    Expression<Geometry>

Output type: GeoPoint

Examples

Example 1: Base case

Argument values:

  • Fraction: fraction
  • Linestring: linestring
linestringfractionOutput
{"type":"LineString","coordinates":[[0.0,2.0],[30.0,0.0]]}0.5{
latitude: 1.0352686301676643,
longitude: 15.004677545504547,
}
{"type":"LineString","coordinates":[[30.0,2.0],[50.0,3.0]]}0.8{
latitude: 2.8256098405656185,
longitude: 45.99752305664789,
}
{"type":"LineString","coordinates":[[45.0,9.0],[90.0,4.0]]}0.2{
latitude: 8.363732883448177,
longitude: 54.073497456494955,
}

Example 2: Base case

Argument values:

  • Fraction: fraction
  • Linestring: linestring
linestringfractionOutput
{"type":"LineString","coordinates":[[0.0,2.0],[30.0,0.0]]}0.5{
latitude: 1.0352686301676643,
longitude: 15.004677545504547,
}
{"type":"LineString","coordinates":[[30.0,2.0],[50.0,3.0]]}0.8{
latitude: 2.8256098405656185,
longitude: 45.99752305664789,
}
{"type":"LineString","coordinates":[[45.0,9.0],[90.0,4.0]]}0.2{
latitude: 8.363732883448177,
longitude: 54.073497456494955,
}

Example 3: Base case

Argument values:

  • Fraction: fraction
  • Linestring: linestring
linestringfractionOutput
{"type":"LineString","coordinates":[[0.0,2.0],[30.0,0.0]]}0.5{
latitude: 1.0352686301676643,
longitude: 15.004677545504547,
}
{"type":"LineString","coordinates":[[30.0,2.0],[50.0,3.0]]}0.8{
latitude: 2.825609851378893,
longitude: 45.99752329517703,
}
{"type":"LineString","coordinates":[[45.0,9.0],[90.0,4.0]]}0.2{
latitude: 8.363732872387065,
longitude: 54.0734975914614,
}

Example 4: Null case

Argument values:

  • Fraction: fraction
  • Linestring: linestring
linestringfractionOutput
{"type":"LineString","coordinates":[[10.0,4.0],[75.0,0.0]]}nullnull
{"type":"LineString","coordinates":[[10.0,8.0],[35.0,0.0]]}-0.5null
{"type":"LineString","coordinates":[[10.0,8.0],[35.0,0.0]]}1.6null
{"type":"MultiLineString","coordinates":[[[100.0,0.0]], [[102.0,2.0]]]}0.4null
{"type":"GeometryCollection","geometries":{"type":"LineString","coordinates":[[10.0,4.0]]}}0.5null
null1.0null

Example 5: Edge case

Description: Fraction values of 0 return a GeoPoint at the start point and fraction values of 1 return a GeoPoint at the end point. There exist floating point errors but should be precise enough for almost all use cases. Argument values:

  • Fraction: fraction
  • Linestring: linestring
linestringfractionOutput
{"type":"LineString","coordinates":[[10.0,4.0],[75.0,0.0]]}0.0{
latitude: 4.0,
longitude: 9.999999999999998,
}
{"type":"LineString","coordinates":[[10.0,8.0],[35.0,0.0]]}1.0{
latitude: 0.0,
longitude: 35.0,
}
{"type":"LineString","coordinates":[[10.0,8.4],[35.0,0.0],[163.0,67.9]]}1.0{
latitude: 67.90000000000002,
longitude: 163.0,
}
{"type":"LineString","coordinates":[[10.0,8.4],[35.0,0.0],[163.0,67.9]]}0.0{
latitude: 8.400000000000002,
longitude: 9.999999999999998,
}