Creation of Buffer zone using Python in QGIS
HTML-код
- Опубликовано: 10 сен 2024
- Hi Viewers,
In this video, you will come to know the python program coding for the creation of buffer zone for point features in QGIS.
Find the program below for your reference.
iface.newProject()
iface.addVectorLayer("d:/msr-geospatial-solutions/qgis-python/points.shp","points", "ogr")
InputFile = 'points'
OutputFile = "d:/msr-geospatial-solutions/qgis-python/bufferzone.shp"
bufferDist = 0.02
##To get the fields from map layer
Data = QgsProject.instance().mapLayersByName(InputFile)
layer = Data[0]
fields = layer.fields()
QGS Vector File Writer will create buffered features and add to output file.
writer = QgsVectorFileWriter(OutputFile, 'UTF-8', fields, \
QgsWkbTypes.Polygon, layer.sourceCrs(), 'ESRI Shapefile')
Geometry along with buffer. Use writer to add the feature to the buffer layer.
for f in layer.getFeatures():
geom = f.geometry()
buffer = geom.buffer(bufferDist, 0.02)
f.setGeometry(buffer)
writer.addFeature(f)
print('done')
Run Python code
##Finally, add the buffered layer to the QGIS interface and delete the writer.
iface.addVectorLayer(OutputFile, '', 'ogr')
del(writer)
Excellent video.. well explained each code lines.. expecting more such videos
Thank you, I will. Keep watching
@@msrgeospatialsolutions could you please share some books or tutorial documents about pyqgis
Great info. Proximity analysis can be done using this easily.
Thank you for comment priya.. Yes, buffer can be done for any feature type. It may be useful as per requirement.
Very good information. Nice presentation.
Thanks a lot. Keep watching for more updates.
Very good information. Really useful for me. Thank you for it
So nice of you. Keep watching
Thank you for this. Please provide more videos using python in qgis.
Thank you. Sure, I will update soon. Keep follow the channel
Very useful Info.
Thank you for comment sir. Keep watch for updates
Wow super sir
Thank you so much. Keep watching
Very nice! I am looking forward to see more Python and QGIS related videos.
Thanks for comment. I will definitely update soon. keep watching.
Awesome video - indeed helpful! also do you know what parameter to change if I wanna create square buffers instead of circles? Thanks!
Thank you for the comments. I will let you know the details, if possible. Keep follow for the updates.
Python is in add in plugs??
Yes, Python is inbuilt in the form of python console in both QGIS and ArcGIS.
@@msrgeospatialsolutions is this running in version 3.30.2-'s-Hertogenbosch?