[GIS] Getting adjacent polygons to merge in QGIS

mergeqgis

I was given a shapefile made up of a few thousand squares. The data in the squares has 5 different values. I wanted to merge all the common values into the same polygon to simplify things. This is what it looked like.

Before Merge

I used the the Select by Expression tool to select all the polygons of the same values and then used the Merge Selected Features tool to merge the polygons together. I was hoping I would be left with 5 geometries that held each value. However after the merge I had vertical stripes through each of the zones as shown here.

After Merge

I suspect that I'm looking at polygons that have points that are not exactly at the same coordinates. I also suspect that it is a problem created by the software program that generated the shapefile. I was able to confirm this by using the Snap tool to move the points and snap it back over the other one and then I could merge the polygons together. I don't have the time nor the patience to do that for every point on the map.

I've tried to use the GRASS clean tools to get rid of these points as well as a few other tools I could find and have searched the forum for solutions, but after an afternoon of not getting anywhere, I've decided to see if anyone could help me figure this out. I've provided the (Shapefile Data) here if someone wants to try to do it.

How do I clean this up?

I'm running 2.18.14.

Best Answer

Here is the workflow on how to solve this problem using your data:

  1. Download Multipart Split from the plugin manager
  2. Start editing your polygon layer -> Select all -> Use Multipart Split tool from step 1 to explode the polygons into separate polygons. (# Singlepart to Multiparts tool did not work)
  3. Agree with @Matte solution, you need to use Snap points to grid from QGIS Geoalgorithms -> Vector general tool -> Snap points to grid with Horizontal and vertical spacing of 0.000001 (the minimum you can).
  4. Use Dissolve tool to merge all the polygon together based on field attribute QGIS Geoalgorithms -> Vector general tool -> Dissolve, and uncheck the option (Dissolve all (do not use field))

enter image description here

Here is the result of step 2:

enter image description here

Result of step 4:

enter image description here

However, there are some missing tinny polygons, and I think this is due to the CRS used. You are using geographic (unprojected) data, and working with unprojected data for cleaning polygons may produce undesired outputs.

Related Question