Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am very new to Python scripting in QuantumGIS, so bear with me please.

I am trying to use the QgsOverlayAnalyzer class in QuantumGIS ( to automate the intersection between different layers (I have plenty of intersections to do).

However, I can't get it to work in the python console.. assume I want to intersect layer1 with layer2, and write the results in C:\shapefile.shp, I am trying something like this with no success:

QgsOverlayAnalyzer.intesection(layer1, layer2, "C:\shapefile.shp", false, 0)

The error I make must be quite serious, as the message I get is:

NameError: name 'QgsOverlayAnalyzer' is not defined

Any help on this is very much appreciated.


share|improve this question

It seems that the correct answer is here.

You can access to that object importing the analysis module:

from qgis import analysis
share|improve this answer
Diegogb, thanks a lot! this is exactly what I was looking for, now it runs like a charme! Quite depressing though that yesterday I surfed the web for a few hours without managing to come across the page you linked me! – Dom Mar 20 '13 at 9:22
@Dom Please upvote helpful answers and accept answers that solve your problem – underdark Mar 20 '13 at 12:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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