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

Clean converts a polygon to a multipolygon of boundary slivers #663

Open
siromega opened this issue Oct 25, 2024 · 2 comments
Open

Clean converts a polygon to a multipolygon of boundary slivers #663

siromega opened this issue Oct 25, 2024 · 2 comments

Comments

@siromega
Copy link

I am working with a set of data, and in the course of my processing, polygons are being diminished from a polygon to just slivers of the outline.

Starting polygon
image

Resulting polygon after "filter-slivers" and "clean allow-overlaps".
image

A regular polygon became just boundary slivers after these two processing steps.

Inspect before the processing:
Type: polygon
Rings: 1 cw, 2 ccw (which goes to 1 cw, 0 ccw after filter-slivers, and to 48 cw 0 ccw after clean allow-overlaps)

The spherical area is also dramatically reduced since it's just a bunch of boundary polygon slivers.

If I run filter-slivers again, it deletes the 48 cw rings, and I have no geometry anymore.

If you need any additional information, please let me know.

@mbloch
Copy link
Owner

mbloch commented Oct 26, 2024

This kind of error can occur because mapshaper's functions for intersection detection are not extremely robust (floating point rounding errors can cause incorrect results).

These errors can also occur when the source data has certain kinds of errors (like incorrect polygon winding order in Shapefiles and incorrect ring/hole order in GeoJSON sources). To check for this kind of error, try running -clean rewind before your original clean command.

If running -clean rewind does not fix the error, I would appreciate it if you could send me a sample file, so I can replicate the error and possibly fix it.

Thanks!

@siromega
Copy link
Author

I tried the clean -rewind, and it did not have an impact.

I reviewed the source data I downloaded to generate the larger combined file. I cleaned up the problem geometry and reprocessed the data, and when I ran the clean on the larger combined file, this time, it preserved the polygon and behaved in the expected way.

The detail I believe made this particular shape a problem was "spikes" from the exterior polygon ring. I cleaned these spikes up by removing the vertices out in space, and the polygon seemed to work better with the clean command.

My issue is solved.

If you are interested in the source polygon that had the spikes, I can give that to you whenever you'd like.

image image image

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

4 participants
@siromega @mbloch and others