Modifier

Partager via


geo_intersection_2lines()

Applies to: ✅ Microsoft FabricAzure Data ExplorerAzure MonitorMicrosoft Sentinel

Calculates the intersection of two lines or multilines.

Syntax

geo_intersection_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

Intersection in GeoJSON Format and of a dynamic data type. 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 calculates intersection between two lines. In this case, the result is a point.

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 intersection = geo_intersection_2lines(lineString1, lineString2)

Output

intersection
{"type": "Point","coordinates": [-73.979837116670978,40.783989289772165]}

The following example calculates intersection between two lines. In this case, the result is a line.

let line = dynamic({"type":"LineString","coordinates":[[-73.978929,40.785155],[-73.980903,40.782621]]});
print intersection = geo_intersection_2lines(line, line)

Output

intersection
{"type": "LineString","coordinates": [[ -73.978929, 40.785155],[ -73.980903, 40.782621]]}

The following two lines don't intersect.

let lineString1 = dynamic({"type":"LineString","coordinates":[[1, 1],[2, 2]]});
let lineString2 = dynamic({"type":"LineString","coordinates":[[3, 3],[4, 4]]});
print intersection = geo_intersection_2lines(lineString1, lineString2)

Output

intersection
{"type": "GeometryCollection", "geometries": []}

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

let lineString1 = dynamic({"type":"LineString","coordinates":[[1, 1],[2, 2]]});
let lineString2 = dynamic({"type":"LineString","coordinates":[[3, 3]]});
print invalid = isnull(geo_intersection_2lines(lineString1, lineString2))

Output

invalid
1