Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-simplify simplifies linestring as if start and end points are connected #573

Open
dc99dc99 opened this issue Feb 17, 2023 · 2 comments
Open

Comments

@dc99dc99
Copy link

Perhaps this is intentional, but if I have a LineString of, say, 100 points where the final point is identical to the first point (this happens a lot on plotted GPS routes), simplifying this line has a tendency to remove a chunk of the start or end of the line. It appears as though mapshaper considers this a continuous line and so simplifies away the first/last point. See attached. If you simplify this any amount significant amount the start and end disappear. Moving the start/end even marginally removes this behaviour.

Is this intentional and is there anything that I can do to prevent it, other than tweaking the points slightly to prevent them being snapped together
example.txt

@mbloch
Copy link
Owner

mbloch commented Feb 18, 2023

You may find that the Douglas Peucker method does a better job of simplifying this kind of linework than the default method (which is based on Visvalingam's algorithm). So try adding method=dp to the simplify command. This method has less of a tendency to remove the most extreme points on a line.

@dc99dc99
Copy link
Author

Thanks - DP does the same thing. It believes the last point in the line is connected to the first point. Perhaps this is mathematically correct, so not something which needs 'fixing'. My solution is to iterate the points and ensure none of them are at the exact same coordinates as the others by introducing some jitter. I can't see any other way to resolve this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants