geo_line_simplify()

Simplifies a line or a multiline by replacing nearly straight chains of short edges with a single long edge on Earth.

Syntax

geo_line_simplify(lineString, tolerance)

Learn more about syntax conventions.

Parameters

Name Type Required Description
lineString dynamic ✔️ A LineString or MultiLineString in the GeoJSON format.
tolerance int, long, or real Defines minimum distance in meters between any two vertices. Supported values are in the range [0, ~7,800,000 meters]. If unspecified, the default value 10 is used.

Returns

Simplified line or a multiline in the GeoJSON format and of a dynamic data type, with no two vertices with distance less than tolerance. If either the line or tolerance 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 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.
  • If input is a multiline and contains more than one line, the result will be simplification of lines union.
  • High tolerance may cause small line to disappear.

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 simplifies the line by removing vertices that are within a 10-meter distance from each other.

let line = dynamic({"type":"LineString","coordinates":[[-73.97033169865608,40.789063020152824],[-73.97039607167244,40.78897975920816],[-73.9704617857933,40.78888837512432],[-73.97052884101868,40.7887949601531],[-73.9706052839756,40.788698498903564],[-73.97065222263336,40.78862640672032],[-73.97072866559029,40.78852791445617],[-73.97079303860664,40.788434498977836]]});
print simplified = geo_line_simplify(line, 10)

Output

simplified
{"type": "LineString", "coordinates": [[-73.97033169865608, 40.789063020152824], [-73.97079303860664, 40.788434498977836]]}

The following example simplifies lines and combines results into GeoJSON geometry collection.

NY_Manhattan_Roads
| project road = features.geometry
| project road_simplified = geo_line_simplify(road, 100)
| summarize roads_lst = make_list(road_simplified)
| project geojson = bag_pack("type", "Feature","geometry", bag_pack("type", "GeometryCollection", "geometries", roads_lst), "properties", bag_pack("name", "roads"))

Output

geojson
{"type": "Feature", "geometry": {"type": "GeometryCollection", "geometries": [ ... ]}, "properties": {"name": "roads"}}

The following example simplifies lines and unifies result

NY_Manhattan_Roads
| project road = features.geometry
| project road_simplified = geo_line_simplify(road, 100)
| summarize roads_lst = make_list(road_simplified)
| project roads = geo_union_lines_array(roads_lst)

Output

roads
{"type": "MultiLineString", "coordinates": [ ... ]}

The following example returns True because of the invalid line.

print is_invalid_line = isnull(geo_line_simplify(dynamic({"type":"LineString","coordinates":[[1, 1]]})))

Output

is_invalid_line
True

The following example returns True because of the invalid tolerance.

print is_invalid_line = isnull(geo_line_simplify(dynamic({"type":"LineString","coordinates":[[1, 1],[2,2]]}), -1))

Output

is_invalid_line
True

The following example returns True because high tolerance causes small line to disappear.

print is_invalid_line = isnull(geo_line_simplify(dynamic({"type":"LineString","coordinates":[[1.1, 1.1],[1.2,1.2]]}), 100000))

Output

is_invalid_line
True