TransWikia.com

Clipping shapefile – QGIS vs Python

Geographic Information Systems Asked on January 22, 2021

Which algorithm does QGIS use for clipping shapefiles?

When I use ogr2ogr to clip a large shapefile (approx. 3gb) it takes 77sec. When using QGIS it takes approx 5 sec, clipping the same dataset (and same mask-layer). New clipped layer is approx 30mb, and the 6sec. includes saving in QGIS

Any suggestions for a better algorithms or modifications of the code below?

Here is the code I use in Python:

import subprocess
clipping_shp = r"C:Pythonbuffer.shp"
output_shp = r"C:Pythonresult.shp"  
input_shp = r'C:Pythondata.shp'
subprocess.call(["ogr2ogr", "-f", "ESRI Shapefile", "-clipsrc", clipping_shp, output_shp, input_shp], shell=True)

One Answer

Which algorithm does QGIS use for clipping shapefiles?

QGIS is Open Source and you can have a look through the code for the clipping algorithm on their GitHub:

https://github.com/qgis/QGIS/blob/04b9c6ab00bb130e590863244b8de64c0f111ae1/src/analysis/processing/qgsalgorithmclip.cpp

Answered by HeikkiVesanto on January 22, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP