simplify_preserve_topology(...) function reduces the number of vertices in a line or polygon using the Ramer–Douglas–Peucker algorithm. This is useful for approximation or for reducing the total size of a geospatial dataset.
simplify(...), this function will not over-simplify geometries.
simplify_preserve_topology(...) takes two arguments:
For example, to get a simplified version of the polygon for the City of Seattle from the Tiger LINE “Places” dataset:
For more information on how simplification works, you should refer to the
ST_Simplify PostGIS function.
One handy use of
simplify_preserve_topology(...) is to generate simplified polygons that work with our
within_polygon(...) function. To use
within_polygon(...), you need to generate a string in Well Known Text, a text markup language for representing geometries, and that string also needs to be fit within the limit of a URL string, which can be as short as 2000 characters for some HTTP client libraries.
Fortunately, our CSV output type already encodes polygons in WKT, and you can use
simplify_preserve_topology(...) with our CSV output. So, if you wanted to fetch a simplified version of the Seattle city boundary to feed into another SoQL query, you could use a call similar to the one above, but change the output type to get you CSV and WKT: