Generalizing a vector layer
Generalizing geometry, also known as simplifying, removes points from a vector layer to reduce the space required to store the data. Otherwise, simplification may result in small but acceptable changes within a specified tolerance.
Getting ready
For this recipe, we will use a boundary file for the state of Mississippi, which you can download from the following URL:
https://github.com/GeospatialPython/Learn/raw/master/Mississippi.zip
Extract the zipped shapefile to a directory named /qgis_data/ms
.
How to do it...
Generalizing is native to QGIS, but we will access it in PyQGIS through the Processing Toolbox using the qgis:simplifygeometries
algorithm.
Start QGIS.
From the Plugins menu, select Python Console.
Import the
processing
module:import processing
Now, we run the processing algorithm specifying the algorithm name, the input data, a tolerance value spacing between points, and the output dataset name:
processing.runandload("qgis:simplifygeometries...