I have two massive shapefiles and I need to create a difference shapefile output between the two. I have a layer where I have satellite coverage (orange) and then a layer where I have high resolution imagery (purple). I'm looking to create a shapefile of only sections where I have satellite coverage but not high resolution imagery. In my case these holes are where Landsat is used.

I'm not to used to doing anything on the command line but am happy to do so if it will work.

I believe the issue here is that the shapefiles are too big themselves (can contain >40k features). None of the default difference tools work when using full shapefiles. Will work for other queries though.

Here's a screenshot of what I'm talking about:

orange is sat coverage, pink if the difference layer (where I have high resolution

The final result that I need is the orange tiles with the areas covered by purple removed.

  • 1
    So I'm guessing orange is sat coverage and purple is high-res? I wouldn't think that the number of features in this case would be the issue - what do the 'default' difference tools do (ie, Difference)? Produce any errors, partial results, fail to complete? My first suggestion would be to dissolve/merge one or both layers into single features. In the case of the grid that will greatly simplify the geometry, though for the purple it's not likely to make a difference since it appears to already be dissolved down to contiguity. BTW, diff gives you either/or, sounds like you want erase/clip.
    – Chris W
    May 8, 2015 at 21:46
  • Chris W., Yes, orange is sat coverage and purple is high res. I've made some progress over the weekend with a difference query but it missed some areas so I'm investigating why at the moment. The problem I'm having is the query can take up to 15-20 hours to complete before I know it if completes or not. It will otherwise just freeze or produce nothing. I'm never given any errors. Here's to hoping this last try will work by tomorrow! :)
    – Matt G
    May 11, 2015 at 16:22
  • The final result that I need is the orange tiles with the areas covered by purple removed. Clip doesn't seem to work for me. Though, the difference tool is doing what I need.
    – Matt G
    May 11, 2015 at 16:23
  • Turns out what I was thinking of as Erase (ArcGIS) is actually called Difference in QGIS and what I thought it would do is what Symmetrical Difference does (in both softwares). Tool name confusion. Clip is another can of worms, because it can either discard or preserve area of intersect depending on implementation. You might run Check Geometry Validity on the two files. I still don't think that number of features should be causing issue, and dissolve orange > diff orange/purple > diff result orange is still my best suggestion for speeding up.
    – Chris W
    May 11, 2015 at 19:43

3 Answers 3


You're looking for the symmetrical difference tool. In my experience it works very similarly to st_disjoint, only it does it in a "masking" style so the underlying shape can be cut out just so.

I struggled with this tool for a while, getting empty outputs, before I discovered a workable solution. Both of my layers were in geographic (EPSG:4326) format beforehand. After I switched them to a local geometric CRS (Georgia stateplane in my case), the tool worked.

Orange is your input layer, the other one is the purple. voila


I was able to resolve this by doing a series of difference queries based on a few shape files I have. Still found not great automated way but it's done nonetheless.


One way to approach this would be using Rasters. Raster operations would be faster and more reliable in this case.

Convert your vector layers to rasters using Raster -> Conversion -> Rasterize. (Start with a large pixel size to test your approach.)

Subtract the rasters using Raster Calculator.

convert the result into Vector using Raster -> Conversion -> Vectorize.

If this works for you, reduce the pixel size to a small enough value that preserves the original shapes to your requirement.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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