TRK_Speed takes a track column and returns a float column representing the speed of each input track. The result is
calculated by dividing the track length by the track duration.
The result is returned in the units specified by output
, which can be Meters
, Nautical
,
Feet
, Kilometers
, or Miles
. This function requires that the input track has a
spatial reference.
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.
Function | Syntax |
---|---|
Python | speed(track, output |
SQL | TRK |
Scala | speed(track, output |
For more details, go to the GeoAnalytics for Microsoft Fabric API reference for speed.
Examples
from geoanalytics_fabric.sql import functions as ST
from geoanalytics_fabric.tracks import functions as TRK
from pyspark.sql import functions as F
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))
df.select(F.round(TRK.speed("track", "MilesPerHour"), 3).alias("speed")).show()
+------+
| speed|
+------+
|57.591|
|50.966|
|35.761|
+------+
Version table
Release | Notes |
---|---|
1.0.0-beta | Python, SQL, and Scala functions introduced |