0

I want to keep only the features from my data layer (polygon A) within my area of interest (AOI). If I compare two methods to perform that, the processing time is very different.

  1. Intersection tool

I find the function Vector--> Geoprocessing Tools-->Intersection can be very slow (sys. time. 3981.78 secondes or 660 times longer). It trims each polygon from the data layer (polygon A) by the limits/edges of the second polygon (AOI) and adds the information from the attribute table of the other layer. For my purposes, this is not necessary.

  1. Select by location... method

In contrast, if I used Vector--> Research Tools-->Select by Location..., it can run very quickly (sys. time. 6 sec.) + selecting the layer and exporting only selected features. This method selects the polygons that overlap (or touch, depending on the settings) without cutting out the portions of the polygons that do not intersect.

Is there another tool that will perform the algorithm efficiently with just one step? I don't need to trim the edges of each polygon in the layer I want to cut, just keep those that over within the area of interest (I think that is the difference in processing time, given that that is the difference in the result between the two methods.

2

Try "extract by location", available in Processing Toolbox under vector selection. This is similar to "select by location", but produces a new layer directly instead of a selection.

  • Even faster than select by location! – user3386170 Jan 3 at 19:58
0

Try PostGIS (you can also use it from within QGIS if PostgreSQL/PostGIS are installed) with some SQL like the following:

select ST_Intersection(a.geom, b.geom) as intersection_ab
from a, b
where ST_Intersects(a.geom, b.geom);

better create a spatial index for both of your layers before applying the query like the following:

CREATE INDEX a_geom_idx ON a USING GIST (geom);  
CREATE INDEX b_geom_idx ON b USING GIST (geom);

I am supposing your layers are of type geometry, but if they are of type geography you just change the index to geog rather than geom.

You could also use extract by location, which will create a new layer after applying the spatial operation.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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