7

I need to clip a large shapefile (600,000 KB) to another smaller shapefile (10 KB). The vector -> geoprocessing -> clip command is taking very long. Answers to similar questions say to use "ogr2ogr" but I am not sure where to start in installing ogr2ogr. I have no Python experience either, not sure if that makes a difference.

1
  • OK, I'll try downloading and using 2.18. (As an aside - does anyone know if 2.18 should speed up other processes in general, like using the field calculator to create a new field for the attribute table for millions of rows of data?)
    – racheldeep
    Commented Oct 15, 2017 at 15:39

2 Answers 2

15

On windows environnement, if you installed Qgis with OSGeoW setup you have access to a shell which can run directly gdal/ogr. to run a clic processing use this command
ogr2ogr -clipsrc clip_polygon.shp output.shp input.shp
replace output and input with your files name and their path.
If you need more details about OSGEOW have a look to this page

9

Upgrade to a recent 2.18 release. From the change log:

" Before the algorithm was written to optimise clipping a few features against thousands of mask features. The revised algorithm is optimised for clipping thousands of input features against a few mask features.

Given that this second operation is much more likely, it makes sense to optimise for this use case.

I've also applied some other optimisations like taking advantage of spatial indexes on the providers, using prepared geometries and also only applying an intersection operation if the geometry isn't wholly contained by the mask geometry.

Benchmarks:

clipping roads layer with 1 million lines against 2 polygons

before: 5 mins 30 seconds after: 10 seconds

clipping address layer with 5 million points against 2 polygons

before: 50 minutes after: 30 seconds"

2
  • well thank you very much for doing that, champion, good'on'ya!
    – guestagain
    Commented Oct 15, 2017 at 2:13
  • Thanks, that worked. QGIS 2.18 really makes a huge difference with clipping. It is buggy, however, with creating new fields in layer|properties (see gis.stackexchange.com/questions/258567/…)
    – racheldeep
    Commented Oct 16, 2017 at 19:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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