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.
2 Answers
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
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"
-
well thank you very much for doing that, champion, good'on'ya! 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/…) Commented Oct 16, 2017 at 19:03