2

I am working with a NaturalEarth country vector dataset (download it here) and I am trying to merge country polygons according to custom regions (based on the UN Geoscheme), in order to only have an outer border rather than every single country's border.

My issue is that, seemingly contiguous countries leave artefacts after merging, be it by hand ("edit > merge selected features") or by using the "dissolve" tool ("vector > geoprocessing tools > dissolve").

How come there are stray lines inside the regions? Can I somehow fix that, or should I find a different dataset?

See the following examples in Africa:

Merging by hand

Selecting a bunch of country polygons and using "merge selected features".

Dissolving according to data

Dissolving polygons that have the same region name.

5
  • 1
    This is because the vertices between adjacent polygons do not precisely match. It would be best to buffer by a small amount before dissolving and then buffer back by negative the previous small amount; you will lose some fine detail but visually the result should be ok. Do you need the polygon for analysis? You could also have a look at gis.stackexchange.com/questions/167865/… to try to coalesce the geometries before dissolving. Commented Apr 20, 2017 at 3:27
  • Cheers @MichaelMiles-Stimson. The buffering sounds like a great solution, but how does one do that? I do not need to be very precise, the map is used as a background for a figure, the data is not used in any analysis afterwards. Feel free to create an answer with more details as this sounds like it might be the solution to my issue.
    – stragu
    Commented Apr 20, 2017 at 3:30
  • docs.qgis.org/2.8/en/docs/gentle_gis_introduction/… shows how to use the QGIS buffer utility. You will have to decide what very small is and will probably need to do several iterations until you're satisfied that artefacts are gone and the essential shape hasn't been corrupted too much. Commented Apr 20, 2017 at 3:33
  • I have been able to buffer + dissolve with great results. Buffering back with a negative value degrades the shape too much, so I am happy to stay with a slightly buffered shape that just lookslike a smoothed coastline, but I end up with slightly overlapping regions. How would I fix that?
    – stragu
    Commented Apr 20, 2017 at 4:10
  • If you can see it perhaps your buffer is too large, try reducing the buffer amount until the artefacts are gone but you can't see the difference, if this is still unsatisfactory you could overlay the polygons with the original other polygons to erase the overlapping areas of adjacent polygons gis.stackexchange.com/questions/62949/… Commented Apr 20, 2017 at 4:15

1 Answer 1

2

The buffer-then-debuffer technique can work well with tiny buffers. As discussed, if you can see the result the buffer is too large. However, even a tiny buffer will degrade the original data to some extent.

A possibly better alternative is to use 'Fill holes' from the Processing toolbox after your dissolve. It is like 'Delete holes' except here you have some control over the size of hole you wish to fill (and so can thereby retain large lakes like Lake Malawi for instance).

Another option would be to download the land boundaries from the Physical 10m data set in Natural Earth and then intersect that with the Admin0 boundary lines from the cultural data. The lines are single lines so shouldn't have the issue of in exact polygon boundaries. This won't work well for island, but you could generate polygons from the lines.

Yet another option would be to do the dissolve and buffer operation as before but then difference the result against the oceans dataset. The Oceans data is the inverse of the land. As the buffer operation will tend to fill in coastal 'wiggles', differencing against the ocean (or indeed, clipping with the land - see link above) should correct the coastline back to how it was.

Finally you could go old-school and using GRASS tools in the Processing tool box, you could clean and build topology (v.clean and v.clean.advanced) and set the snapping tolerance (something small initially) before you do your dissolve operation. Having 'grown-up' with ArcInfo 6.x, I'd be inclined to go old-school. Good topology makes for happy geographers.

Not the answer you're looking for? Browse other questions tagged or ask your own question.