[postgis-devel] ST_Simplify vs ST_SimplifyVW

Nicklas Avén nicklas.aven at jordogskog.no
Wed Jun 3 12:19:44 PDT 2015


Hello

I would like to raise a few questions about the 2 simplification
functions ST_Simplify and ST_SimplifyVW

The 2 functions have some differences in behavior.

The main difference between the 2 functions is that ST_Simplify uses
Douglas-Pecker algorithm and ST_SimplifyVW uses Visvalingam-Whyatt
algorithm.

The 2 functions gives different result and have very different
sensitivity on the threshold value. So far nothing to discuss.

Here is 3 other differences:

1)
When using ST_Simplify, points is removed also when used with 0 as
tolerance if they doesn't affect the line. In ST_SimplifyVW those points
isn't removed. The reason is that it is the same function as
ST_SetEffectiveArea. And in htat context it would be wrong to remove any
points. That is not the purpose of the function. 
My question here is:
Is that difference acceptable or should I put some effort in
differentiate the behavior when called from ST_SimplifyVW from when
called from ST_SetEffectiveArea?

2)
This is just a question about how to describe in the doc about the
difference. Since Visvalingam-Whyatt algorithm only compares area in
triangels, it is possible to treat geoemtries in 3d-space the same way
as geoemtries in 2d-space. The triangel is only 2d any way, just
rotated. The result is a function that is sensitive also to significans
in third dimension. This gives a difference in behavior that I want help
to describe in a good way. And should it be described both in
ST_Simplify and ST_SimplifyVW or only in ST_SimplifyVW?

See the difference by running:
SELECT  ST_AsText(ST_Simplify(ST_Force2D(geom),1)) "2D ST_Simplify",
ST_AsText(ST_SimplifyVW(ST_Force2D(geom),1)) "2D
ST_SimplifyVW",ST_AsText(ST_Simplify(geom,1)) "3D ST_Simplify",
ST_AsText(ST_SimplifyVW(geom,1)) "3D ST_SimplifyVW" from 
(select 'LINESTRING(0 0 0, 0 10 10, 0 20 0)'::geometry geom) l

When forced to 2d, both functions return the same by removing the middle
point. But in the 3d cse, ST_Simplify finds that the middle point
affects the line since it isn't a straight line in 3d-space. But
ST_Simplify still removes the middle point.

3)
This one is maybe on it's way away because of the ticket with
controlling the collapsing behavior. But now ST_Simplify collapses
polygons. ST_SimplifyVW collapses interior rings but preserves the
boundary with the 4 most significant points.

test by running:
select ST_AsText(ST_Simplify(geom,100)),
ST_AsText(ST_SimplifyVW(geom,1000)) from 
(select 'POLYGON((1 1, 1 30, 2 32, 8 40, 40 40, 38 10, 35 1, 1 1), (5 5,
5 9, 9 9, 9 5, 5 5))'::geometry geom ) p

I think the behavior of ST_SimplifyVW is what ST_Simplify is aiming at.
But it is not there now.

If it is supposed to collapse polygons also in the future maybe that
difference should also be documented.



What I think about is if we should have a table also oncluding
ST_SimplifyPreserveTopology describing the differences, and if so, where
in the doc should that be?

Thanks

Nicklas




More information about the postgis-devel mailing list