So I have two polygon layers, polygons in one layer are greater than in the other one. In some cases it is possible to merge smaller polygons so that they fit within the boundaries of a bigger polygon. Is there a way to do it in QGIS automatically and attribute the ID number of a bigger polygon to all smaller polygons falling within its boundaries? Trying spatial join did not result: when using Spatial join predicate "within" Qgis only does operation for polygons that do not intersect with any other bigger polygon (see highlighted in yellow on green), and gives NULL for small polygons that are still within one bigger polygon but intersect another bigger polygon. Using spatial join "intersect" results in duplicates and triplicates of smaller polygons with ID numbers of ALL polygons they intersect with. So, all the polygons highlighted in yellow on violet background will receive ID number of the polygon they belong to, but then will be duplicated with ID number of a bigger polygon they border with. I want to get the smaller polygons with the ID number of only one bigger polygon, the one they belong to, so that I will be able to merge them based on that ID number. I do not want to get duplicates and triplicates of the same features with IDs from bordering bigger polygons.
1 Answer
Use the tool
join attributes by location
to add some unique ID value from the large polygon layer to the smaller polygon layer. Use the geometry predicate "within".Use the tool
dissolve
to merge the small polygons that have matching unique ID field values.
-
Unfortunately "within" only works for small polygons that are entirely inside a larger polygon, but it does not work if a small polygons borders another larger polygon. For example, for all smaller polygons on the image Qgis returns an empty field for ID value, because they all border other larger polygons. If I use intersect or overlap, Qgis returns several polygons with different ID values (one value for the polygons that overlaps plus several for bordering polygons), so i should manually eliminate those that were not attributed correctly and it is very time-consuming. Commented Jan 10, 2020 at 13:23
-
I thought you only wanted to merge small polygons that fall within larger polygons. Isn't that what you meant by "it is possible to merge smaller polygons so that they fit perfectly within the boundaries of a bigger polygon"? Please edit your question and elaborate on exactly what relationship your two layers have to each other.– cskCommented Jan 10, 2020 at 17:20
-
Yes, I want small polygons in one layer that fall within the boundaries of a greater polygon from another layer to merge. The problem is that when i use "within" predicate, small polygons that still fully inserted in a larger polygon BUT touch other larger polygons (like those on the picture) get NULL values, they dont receive attributed of the polygon they are inserted in, because apparently "within" predicate only work for polygons that do not share common border with other large polygons. Would be easier to describe with a picture but i dont see how i can attach a pic to my comment. Commented Jan 13, 2020 at 17:09
-
Please update your question with additional information. You can add a picture there.– cskCommented Jan 14, 2020 at 16:03