TRK_IsValid

TRK_IsValid takes a linestring column and returns a boolean column where True indicates that a linestring is a valid track and False indicates that a linestring is not a valid track.

A linestring is considered a valid track if all of the following criteria are met:

  • The linestring is not null.
  • The linestring is not empty.
  • The linestring has M-values that are distinct and increasing.

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 Engine, see the core concept topic on tracks.

FunctionSyntax
Pythonis_valid(track)
SQLTRK_IsValid(track)
ScalaisValid(track)

For more details, go to the GeoAnalytics Engine API reference for is_valid.

Examples

PythonPythonSQLScala
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
from geoanalytics.tracks import functions as TRK
from geoanalytics.sql import functions as ST

data = [
    ("LINESTRING M (-117.27 34.05 1633455010, -117.22 33.91 1633456062)",),
    ("LINESTRING (-116.89 33.96, -116.71 34.01, -116.66 34.08)",),
    ("LINESTRING M EMPTY",)
]

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

df.select("track", TRK.is_valid("track").alias("is_valid")).show(truncate=False)
Result
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
+------------------------------------------------------------------------------------+--------+
|track                                                                               |is_valid|
+------------------------------------------------------------------------------------+--------+
|{"hasM":true,"paths":[[[-117.27,34.05,1.63345501e9],[-117.22,33.91,1.633456062e9]]]}|true    |
|{"paths":[[[-116.89,33.96],[-116.71,34.01],[-116.66,34.08]]]}                       |false   |
|{"hasM":true,"paths":[]}                                                            |false   |
+------------------------------------------------------------------------------------+--------+

Version table

ReleaseNotes

1.4.0

Python and SQL functions introduced

1.5.0

Scala function introduced

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