TRK_Query

TRK_Query takes a track column and an offset and returns a point. The result represents the location that is the offset distance or offset duration along the input track, measured from the track start.

An offset column can be created with ST_CreateDistance or ST_CreateDuration. You can also define an offset with a tuple containing a number and a unit string (e.g., (10, "kilometers") or (5, "minutes")).

Tracks are linestrings that represent the change in an entity's location over time. Each vertex in the linestring has a timestamp (stored as the M-value) and the vertices are ordered sequentially.

For more information on using tracks in GeoAnalytics for Microsoft Fabric, see the core concept topic on tracks.

FunctionSyntax
Pythonquery(track, offset)
SQLTRK_Query(track, offset)
Scalaquery(track, offset)

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

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
17
18
from geoanalytics_fabric.sql import functions as ST
from geoanalytics_fabric.tracks import functions as TRK

data = [
    ("LINESTRING M (-117.27 34.05 1633455010, -117.22 33.91 1633456062, -116.96 33.64 1633457132)",),
    ("LINESTRING M (-116.89 33.96 1633575895, -116.71 34.01 1633576982, -116.66 34.08 1633577061)",),
    ("LINESTRING M (-116.24 33.88 1633575234, -116.33 34.02 1633576336)",)
]

df = spark.createDataFrame(data, ["wkt"]).withColumn("track", ST.line_from_text("wkt", srid=4326))

result = df.withColumn("query", TRK.query("track", (10, "kilometers")))

ax = result.st.plot("track", edgecolor="lightgrey", zorder=0, linewidths=10, figsize=(15, 8))
result.st.plot("query", ax=ax, facecolor="red", s=75, zorder=1)
ax.legend(['Input track','Query result'], loc='lower right', fontsize='x-large')
Plotted example for TRK_Query
Plotted result for TRK_Query.

Scala Example

Scala
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import com.esri.geoanalytics.sql.{functions => ST}
import com.esri.geoanalytics.sql.{trackFunctions => TRK}
import org.apache.spark.sql.{functions => F}

case class lineRow(lineWkt: String)

val data = Seq(lineRow("LINESTRING M (-117.27 34.05 1633455010, -117.22 33.91 1633456062, -116.96 33.64 1633457132)"),
               lineRow("LINESTRING M (-116.89 33.96 1633575895, -116.71 34.01 1633576982, -116.66 34.08 1633577061)"),
               lineRow("LINESTRING M (-116.24 33.88 1633575234, -116.33 34.02 1633576336)"))

val df = spark.createDataFrame(data)
              .withColumn("track", ST.lineFromText($"lineWkt", F.lit(4326)))
              .withColumn("query", TRK.query($"track",  F.lit(struct(F.lit(10), F.lit("kilometers")))))

df.select("query").show(truncate = false)
Result
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
+-------------------------------------------------------------------------+
|query                                                                    |
+-------------------------------------------------------------------------+
|{"x":-117.23913930875534,"y":33.963590064514946,"m":1.6334556593089437e9}|
|{"x":-116.78733351803794,"y":33.988518467211684,"m":1.6335765149914773e9}|
|{"x":-116.291086592492,"y":33.95946803276533,"m":1.6335758595269437e9}   |
+-------------------------------------------------------------------------+

Version table

ReleaseNotes

1.0.0-beta

Python, SQL, and Scala functions introduced

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