rmapshaper icon indicating copy to clipboard operation
rmapshaper copied to clipboard

underlying algorithm

Open mdsumner opened this issue 5 years ago • 3 comments

I'm interested in apply the underlying Visvalingam algorithm directly to paths, do you know if it's available in R independently of the mapshaper interface?

The approach for sf polygons could be taken to identify shared boundaries, simplify those and then piece back together. I've tried this with smoothr and it seems to work:

https://github.com/hypertidy/silicate/issues/64

Obviously I'd have to write all the de- and re- compose code for sf, but I've found easier ways than the current ARC approach shown there, so first examples could use lines.

mdsumner avatar Dec 11 '18 20:12 mdsumner

Looks very cool @mdsumner. Unfortunately I've never seen it implemented in R...

ateucher avatar Dec 11 '18 23:12 ateucher

I think I understand it! I put up an early stab here, it's no use for sf yet and lots to do still. I also assume there are cases when the disconnected shared boundaries will intersect others after simplification, so mapshaper must do some extra checks somehow.

https://github.com/mdsumner/simpler

mdsumner avatar Dec 12 '18 03:12 mdsumner

Fantastic! Thanks @mdsumner. mapshaper does to post-checks and repairs intersections. From the wiki:

By default, mapshaper rolls back simplification along pairs of intersecting line segments by re-introducing removed points until either the intersection disappears or there are no more points to add.

ateucher avatar Dec 13 '18 18:12 ateucher