snowflake.snowpark.functions.st_simplify

snowflake.snowpark.functions.st_simplify(geography_or_geometry_expression: Union[snowflake.snowpark.column.Column, str], tolerance: Union[snowflake.snowpark.column.Column, str], preserve_collapsed: Union[snowflake.snowpark.column.Column, str] = None)[source]

Returns a simplified version of the input GEOGRAPHY or GEOMETRY object by removing points that are deemed unnecessary for the shape.

Parameters:
  • geography_or_geometry_expression (ColumnOrName) – A GEOGRAPHY or GEOMETRY object to be simplified.

  • tolerance (ColumnOrName) – The tolerance value used for simplification. Points closer than this distance may be removed.

  • preserve_collapsed (ColumnOrName, optional) – A boolean value indicating whether to preserve collapsed geometries. Defaults to None.

Returns:

A simplified GEOGRAPHY or GEOMETRY object.

Return type:

Column

Examples::
>>> from snowflake.snowpark.functions import to_geography, to_geometry, lit
>>> df1 = session.create_dataframe([
...     ["LINESTRING(-122.306067 37.55412, -122.32328 37.561801, -122.325879 37.586852)"]
... ], schema=["geog_wkt"])
>>> df1.select(st_simplify(to_geography(df1["geog_wkt"]), lit(1000)).alias("simplified")).collect()
[Row(SIMPLIFIED='{\n  "coordinates": [\n    [\n      -1.223060670000000e+02,\n      3.755412000000000e+01\n    ],\n    [\n      -1.223258790000000e+02,\n      3.758685200000001e+01\n    ]\n  ],\n  "type": "LineString"\n}')]
Copy
>>> df2 = session.create_dataframe([
...     ["LINESTRING(1100 1100, 2500 2100, 3100 3100, 4900 1100, 3100 1900)"]
... ], schema=["geom_wkt"])
>>> df2.select(st_simplify(to_geometry(df2["geom_wkt"]), lit(500)).alias("simplified")).collect()
[Row(SIMPLIFIED='{\n  "coordinates": [\n    [\n      1.100000000000000e+03,\n      1.100000000000000e+03\n    ],\n    [\n      ...0000000e+03\n    ],\n    [\n      3.100000000000000e+03,\n      1.900000000000000e+03\n    ]\n  ],\n  "type": "LineString"\n}')]
Copy
>>> df3 = session.create_dataframe([
...     ["LINESTRING(-122.306067 37.55412, -122.32328 37.561801, -122.325879 37.586852)"]
... ], schema=["geog_wkt"])
>>> df3.select(st_simplify(to_geography(df3["geog_wkt"]), lit(1000), lit(True)).alias("simplified")).collect()
[Row(SIMPLIFIED='{\n  "coordinates": [\n    [\n      -1.223060670000000e+02,\n      3.755412000000000e+01\n    ],\n    [\n      -1.223258790000000e+02,\n      3.758685200000001e+01\n    ]\n  ],\n  "type": "LineString"\n}')]
Copy