Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

My problem:

I have 3 polygons (a, b, c) on layer 1 and two other polygons (1 and 2) on layer 2. Now I want to "crop and melt" (forgive me I don't know the terminus technicus) my three polygons (a,b,c) with the polygons (1 and 2) that (on a new layer) I have two new areas: area I (marked in red in my picture) and area II (marked in blue in my picture). Each of my new areas has two parts.

enter image description here

Thank you very much!

share|improve this question
    
+1 for the drawings. –  Pablo Nov 4 '11 at 13:47
add comment

2 Answers

up vote 3 down vote accepted

The "Intersect" tool in "Geoprocessing tools" should do what you want.

share|improve this answer
    
Hello underdark! Thank you very much for your support. It works, but I have combine the seperate parts for the new areas manually. E.g. I have to combine the 2 "red" polygons manually to a new area and so on. With lots of polygons / new areas a lot of work. I am lazy, is there a way to let qgis do this "automagically"? Kurt –  Kurt Nov 4 '11 at 11:15
    
Kurt, do you have any experience with python or Postgis? –  Pablo Nov 4 '11 at 13:49
    
@Pablo: some experience with python, but no experience with Postgis –  Kurt Nov 4 '11 at 13:52
    
There is a single-part to multi-part tool too. Maybe that could combine the polygons automagically. –  underdark Nov 7 '11 at 12:50
add comment

With some Python code you can create a small program to make this operations and automate the process:

There are many option, I will list 3 popular ones:

  1. GDAL/OGR Python API
  2. Shapely Python library
  3. Qgis Python API

OGR and Qgis API has a very similar structure to deal with vectors, IMO you can try Qgis API first because learning it will allow you to talk to the genie of the lamp that lives inside Qgis, he will do all the magic for you.

The Qgis API basic structure for vector is like this:
Qgis Interface -> Layers -> Features -> Geometry
You will perform the operation in the geometry level.

A good start is the PyQgis cookbook and the python plugins available in Qgis.

share|improve this answer
add comment

Your Answer

 
discard

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.