mbloch / mapshaper

Tools for editing Shapefile, GeoJSON, TopoJSON and CSV files
http://mapshaper.org
Other
3.75k stars 532 forks source link

Command to remove splinter polygons #88

Open mbloch opened 9 years ago

mbloch commented 9 years ago

Splinter polygons can form as a byproduct of some operations, like clipping and erasing. There should be a way to remove these. Perhaps the clip/erase commands should automatically filter out splinters as a final processing step.

A related problem is removing tiny gaps that can form, e.g. by dissolving polygons with topology errors.

mijamo commented 8 years ago

I was looking for this option. I used dissolve to get the outer border of a set of polygons, but unfortunately those polygons were not corresponding in some areas (typically, in the middle of lakes ...) so I have the external border and many very tiny polygons in the middle of all the lakes. I tried to remove them with filter-islands but filter-islands only filters independant polygons and not the ones situated inside of a polygon. So in fact I am a bit without solution to do that right now. It would be good to have something like filter-holes which would act in a similar way to filter-islands but would filter inner rings instead of outer rings.

mbloch commented 8 years ago

There is a command that is not documented, because I haven't had a chance to use it yet in my own work... perhaps you can try it out for me? It's called "filter-slivers", and it takes a min-area= option just like "filter-islands". It sounds like "filter-slivers" might work for you in this situation.

mijamo commented 8 years ago

I tried it and it worked! How great is that ? Pretty awesome! :dancer:

Thank you for the quick answer. Is there a reason why it is not documented ? Is it unstable or did you just not have the time to document it ?

mbloch commented 8 years ago

I think I had originally planned to add the ability to fill in small gaps between two different polygons. The current version only removes small space-filling polygon rings and small holes inside a single polygon. Since you found it useful, I'll go ahead and add documentation for the command in its current state.

mijamo commented 8 years ago

Yes it was actually exactly my use case as I used it chained with dissolve, and slivers were the results of a mismatch between internal polygons.

Fill small gaps between polygons would be a nice feature as well but IMHO it could be yet another function, and I think it should also handle the case of overlapping borders. For example I also have to handle the nice connection between polygons from different sources (for example municipality border and inner city neighbourhoods) and it is annoying because sometimes you have small gaps between polygons, and sometimes two polygons overlap on small areas. But I think it is a much more complex function and would deserve another ticket.

kdanaher commented 5 years ago

Chiming in here because this came up for me recently:

A way to identify the slivers/gaps between polygons, and optionally dissolve them with longest shared border/area would be great. This could be necessary when topology is bad enough and a snapping and cleaning won't quite do the trick.

The only concern would be handling intentional gaps (lakes/water polys).