1

I am trying to add the boundaries of one shapefile (A) that are contained within a single polygon to the shapefile (B) of that single polygon. Both are at the same projection. I have tried clipping, intersecting, union, etc. but have not been able to accomplish it.

example http://radslav.slavniklabs.net/dwnld/problem.jpg

Can anyone provide step-by-step instructions on how to accomplish this using QGIS 2.10.1-Pisa?

When I use Geoprocessing/Clip A(DouglasCountyNE2) with B(sitearea2) the dialog looks like this:

dialog http://radslav.slavniklabs.net/dwnld/clipdialog.png

The result is testomaha.shp but the attribute table is empty:

results http://radslav.slavniklabs.net/dwnld/clipresult-nothing.png

If I use Geoprocessing/Difference the result includes areas beyond the area B as seen below:

difference http://radslav.slavniklabs.net/dwnld/difference.png

This is because it did not clip the areas in A to match B.

Here is a link to a zipfile with both shapefiles in it:

http://tinyurl.com/qdf7dhu

  • So what do you get as a result and why doesn't it work? Clipping A using B or intersecting the two should work. I do note that the boundaries aren't coincident between the two shapefiles, so if you just want to subset A using the boundary of B, a select and export would be cleaner. – Chris W Nov 11 '15 at 1:31
  • I get one of two results: 1. Nothing is added to the polygon B 2. It adds all of the shapes that intersect rather than clipping and eliminating that part of shapes from A that are not within B. – Sudeten Nov 11 '15 at 1:58
  • I would be glad to provide the 2 shape files if that would help. – Sudeten Nov 11 '15 at 1:59
  • The clip should definitely give you clipped features from layer A (smaller polygons - DouglasCountyNE2) within layer B (1 big polygon - sitearea2). There are two reasons I can think of why you get empty result. First is that the layers are not in the same projection. You can Save as... both layers into the same projection just to make really sure. The second is invalid geometry in one or both of the files. Providing link to zip archive with layers could be useful. – Miro Nov 11 '15 at 4:17
  • @Miro may be on to something there. While both shapes are in the same projection, your site layer has geometry errors - specifically a self-intersection in the lower right corner. You might try correcting that and seeing if clip works. Note the DIfference tool gives a result of everything that is not in common between the two files - so what you're getting appears to be correct (except it isn't cutting shapes, which I don't fully understand). I'll reiterate that clip/intersect/whatever is going to trim your A shapes. If you want full A shapes generally covered by B, use a select/export. – Chris W Nov 11 '15 at 20:30
2

In this case the reason why clip doesn't work is invalid geometry. As I mentioned in the comment before:

The clip should definitely give you clipped features from layer A (smaller polygons - DouglasCountyNE2) within layer B (1 big polygon - sitearea2).

There are two reasons I can think of why you get empty result. First is that the layers are not in the same projection. You can Save as... both layers into the same projection just to make really sure (In this particular case the layers are i the same CRS so problem is elsewhere). The second is invalid geometry in one or both of the files. And that is the case here - layer B (1 big polygon - sitearea2) has 2 geometry errors.

In QGIS you can find out through Vector / Geometry tools / Check geometry validity... and then try to manually replace the errors or use some of the tools intended for removing these kind of errors.

Generally on of the simplest ways is to run from Advanced interface of Processing /Toolbox tool called GRASS - Vector - v.clean. You can leave default cleaning tool, GRASS should take care of all basic geometry errors anyway.

In the new QGIS 2.12 there is also new internal plugin called Check Geometries which after turning it on in Plugins / Manage and Install Plugins... you can use from Vector / Geometry tools / Check Geometries (please be aware at this moment after activating the plugin there are two items with the same name Geometry tools in the menu - seems like small QGIS bug).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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