I work in a little companie where the main goal of employees in GIS is to have a quick view of the issues on a study area.

It would be very useful to have a tool wich clip all the layers of the current map extent with the study area.

I made a quick search in ogr tools but I didn't find the appropriate one. Plus, I think that ogr can't work automatically with the current layers.

So I think the solution is Pyqgis but I have no skills in Python.

Is there an existing tool ? Any suggestions to find the simpliest way to do that ?


  • What format is your data in? And do you have SQL skills? If you had your data in PostGIS you could use PostGIS query layers. – James S Aug 5 '13 at 12:25
  • I'm using Spatialite through QSpatialite. I have very basic skills in SQL but I didn't see a "Clip" function in Spatialite. – Samy-DT Aug 5 '13 at 12:36
  • You can use an Intersection query to return the area that intersects the study area and the other layers. gaia-gis.it/spatialite-2.0/spatialite2_sql.html (I haven't actually tried it using spatialite with QGIS but this would be the function you need) – James S Aug 5 '13 at 12:53

More specifically, if you have in spatialite a polygon layer "study_area" and another polygon layer "issue", then you would do:

Create a new table for the clipped issue

CREATE TABLE issue_clipped (pk_uid integer primary key autoincrement, 
   issue_name text,
   <any additional fields you need from the issue table> )

SELECT AddGeometryColumn('issue_clipped','geometry',<the CRS id>, 'POLYGON', 'XY');

Now populate the new issue_clipped table as follows:

INSERT INTO issue_clipped (issue_name, geometry)
SELECT issue_name, ST_INTERSECTION(issue.geometry, study_area.geometry)
FROM issue, study_area
WHERE ST_Intersects(issue.geometry, study_area.geometry);
| improve this answer | |
  • Thanks James S and Micha for the advices but I'm not sure to understand. My aim is to clip multiple layers with one. But St_Intersection takes only two layers in arguments. Micha, I didn't understand what is the "issue_clipped" table that you create before the intersection. Will it receive all the clip results ? Do I need to put the multiple tables in the FROM ? – Samy-DT Aug 6 '13 at 7:24
  • You need to run a query for each layer you want to clip/intersect with your study area table. You could also run the queries in QGIS in DB Managers SQL window. That way they would be a query layer in the QGIS project, without creating new tables in your database - see gis.stackexchange.com/questions/54738/… – James S Aug 6 '13 at 9:28
  • The issue_clipped table is the new table, clipped to the study area. As James pointed out, you'll havea to run this query multiple times for each "issue" layer. – Micha Aug 7 '13 at 14:22
  • 1
    So what is the benefit over "intersection" tool in the vector menu ? It is not an automated process... – Samy-DT Aug 12 '13 at 5:14
  • It is not automated, but what is preventing you from automating this? Or from automating the intersection tool? – Barrett Sep 2 '14 at 18:05

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.