geo_intersects_2lines()

Applies to: ✅ Microsoft FabricAzure Data ExplorerAzure MonitorMicrosoft Sentinel

Calculates whether two lines or multilines intersect.

Syntax

geo_intersects_2lines(lineString1,lineString2)

Learn more about syntax conventions.

Parameters

Name Type Required Description
lineString1 dynamic ✔️ A line or multiline in the GeoJSON format.
lineString2 dynamic ✔️ A line or multiline in the GeoJSON format.

Returns

Indicates whether two lines or multilines intersect. If lineString or a multiLineString are invalid, the query will produce a null result.

Note

  • The geospatial coordinates are interpreted as represented by the WGS-84 coordinate reference system.
  • The geodetic datum used to measure distance on Earth is a sphere. Line edges are geodesics on the sphere.
  • If input line edges are straight cartesian lines, consider using geo_line_densify() in order to convert planar edges to geodesics.

LineString definition and constraints

dynamic({"type": "LineString","coordinates": [[lng_1,lat_1], [lng_2,lat_2], ..., [lng_N,lat_N]]})

dynamic({"type": "MultiLineString","coordinates": [[line_1, line_2, ..., line_N]]})

  • LineString coordinates array must contain at least two entries.
  • Coordinates [longitude, latitude] must be valid where longitude is a real number in the range [-180, +180] and latitude is a real number in the range [-90, +90].
  • Edge length must be less than 180 degrees. The shortest edge between the two vertices will be chosen.

Tip

Use literal LineString or MultiLineString for better performance.

Examples

The following example checks whether some two literal lines intersects.

let lineString1 = dynamic({"type":"LineString","coordinates":[[-73.978929,40.785155],[-73.980903,40.782621]]});
let lineString2 = dynamic({"type":"LineString","coordinates":[[-73.985195,40.788275],[-73.974552,40.779761]]});
print intersects = geo_intersects_2lines(lineString1, lineString2)

Output

intersects
True

The following example finds all roads in the NYC GeoJSON roads table that intersects with some lines of interest.

let my_road = dynamic({"type":"LineString","coordinates":[[-73.97892951965332,40.78515573551921],[-73.98090362548828,40.78262115769851]]});
NY_Manhattan_Roads
| project name = features.properties.Label, road = features.geometry
| where geo_intersects_2lines(road, my_road)
| project name

Output

name
Broadway
W 78th St
W 79th St
W 80th St
W 81st St

The following example will return a null result because one of lines is invalid.

let lineString1 = dynamic({"type":"LineString","coordinates":[[-73.978929,40.785155],[-73.980903,40.782621]]});
let lineString2 = dynamic({"type":"LineString","coordinates":[[-73.985195,40.788275]]});
print isnull(geo_intersects_2lines(lineString1, lineString2))

Output

print_0
True