0

I have two polygon layrers, each layer a table in PostgreSQL: One layer with polygons areas in a city. Another layer with buildings (polygons) that are within areas.

How can I to do to know what buildings are in each areas? Can I have a list or csv with that information?

Something like: layer1(area) -> layer1, 3, 4 (buildings)

Thank you

  • You need to reword the question. Is it simple thing of selecting the polygons within an area and saving them out as a CSV file? – Ger May 3 '13 at 8:47
  • Thks Gerald. Yes the question is this.Select the polygons within an area (this area is also a polygon of a layer) and saving them out as a CSV file – user1573901 May 3 '13 at 8:59
1

Try Vector > Reserch Tools > Then Slect features from the buildings layer that intersect with the base layer.

Then close. Right click on the buildings layer. Save selection as Comma Seperated Value. And that is it I think..

Hopefully on the point here. if not I will remove this as could confuse things.

| improve this answer | |
  • Thks Geral, This creayes a csv just with the ID of one of the layers, I want with two layers, like: layer1(area) -> layer1, 3, 4 (buildings) – user1573901 May 3 '13 at 10:32
  • I want to know what building ID's are in each areas – user1573901 May 3 '13 at 10:49
  • guessing at this but open to suggestions. Why not take the layers you want and combine them to one layer under the data management tool. I have not tried it but will now. I am guessing it should do it but dont know how the results will come out. – Ger May 3 '13 at 12:14
0

If your tables are spatial (you didn't mention if this is a PostGIS database?) then use ST_Contains:

SELECT a.id, b.id 
FROM areas AS a, buildings AS b
WHERE ST_Contains(a.geom, b.geom)
GROUP BY a.id;

More details here

| improve this answer | |
  • hi Micha, yes is a PostGIS. – user1573901 May 3 '13 at 16:27

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.