geo_union_lines_array()

Calculates the union of lines or multilines on Earth.

Syntax

geo_union_lines_array(lineStrings)

Learn more about syntax conventions.

Parameters

Name Type Required Description
lineStrings dynamic ✔️ An array of lines or multilines in the GeoJSON format.

Returns

A line or a multiline in GeoJSON Format and of a dynamic data type. If any of the provided lines or multilines is 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 for measurements on Earth is a sphere. Polygon 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.

Examples

The following example performs geospatial union on line rows.

datatable(lines:dynamic)
[
    dynamic({"type":"LineString","coordinates":[[-73.95683884620665,40.80502891480884],[-73.95633727312088,40.8057171711177],[-73.95489156246185,40.80510200431311]]}),
    dynamic({"type":"LineString","coordinates":[[-73.95633727312088,40.8057171711177],[-73.95489156246185,40.80510200431311],[-73.95537436008453,40.804413741624515]]}),
    dynamic({"type":"LineString","coordinates":[[-73.95633727312088,40.8057171711177],[-73.95489156246185,40.80510200431311]]})
]
| summarize lines_arr = make_list(lines)
| project lines_union = geo_union_lines_array(lines_arr)

Output

lines_union
{"type": "LineString", "coordinates": [[-73.956838846206651, 40.805028914808844], [-73.95633727312088, 40.8057171711177], [ -73.954891562461853, 40.80510200431312], [-73.955374360084534, 40.804413741624522]]}

The following example performs geospatial union on line columns.

datatable(line1:dynamic, line2:dynamic)
[
    dynamic({"type":"LineString","coordinates":[[-73.95683884620665,40.80502891480884],[-73.95633727312088,40.8057171711177],[-73.95489156246185,40.80510200431311]]}), dynamic({"type":"LineString","coordinates":[[-73.95633727312088,40.8057171711177],[-73.95489156246185,40.80510200431311],[-73.95537436008453,40.804413741624515]]})
]
| project lines_arr = pack_array(line1, line2)
| project lines_union = geo_union_lines_array(lines_arr)

Output

lines_union
{"type": "LineString", "coordinates":[[-73.956838846206651, 40.805028914808844], [-73.95633727312088, 40.8057171711177], [-73.954891562461853, 40.80510200431312], [-73.955374360084534, 40.804413741624522]]}

The following example returns True because one of the lines is invalid.

datatable(lines:dynamic)
[
    dynamic({"type":"LineString","coordinates":[[-73.95683884620665,40.80502891480884],[-73.95633727312088,40.8057171711177],[-73.95489156246185,40.80510200431311]]}),
    dynamic({"type":"LineString","coordinates":[[1, 1]]})
]
| summarize lines_arr = make_list(lines)
| project invalid_union = isnull(geo_union_lines_array(lines_arr))

Output

invalid_union
True