January 2019
Beginner
164 pages
3h 15m
English
Open a new project in QGIS. Copy the following code to the editor:
## BufferingAirport_layer = iface.addVectorLayer('D:/QGIS_quickstart/qgis_sample_data/shapefiles/airports.shp','airports','ogr')param = { 'INPUT' : Airport_layer, 'DISTANCE' : 15000, 'SEGMENTS' : 5, 'END_CAP_STYLE' : 0, 'JOIN_STYLE' : 0, 'MITER_LIMIT' : 2, 'DISSOLVE' : False, 'OUTPUT' : 'memory:' }algoOutput = processing.run("qgis:buffer", param)Airport_buffer = QgsProject.instance().addMapLayer(algoOutput['OUTPUT'])
The code in this script loads the airports layer, sets the buffering parameters (param), calls the qgis buffer with the processing.run command, and then adds a layer called OUTPUT to the map.
You can download data from here: https://github.com/PacktPublishing/QGIS-Quick-Start-Guide/blob/master/Chapter07/03_Buffer_Airport.py ...
Read now
Unlock full access