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)

Комментарии • 22

  • @r1188rhhh
    @r1188rhhh 3 года назад +2

    Excellent video.. well explained each code lines.. expecting more such videos

    • @msrgeospatialsolutions
      @msrgeospatialsolutions  3 года назад +1

      Thank you, I will. Keep watching

    • @r1188rhhh
      @r1188rhhh 3 года назад

      @@msrgeospatialsolutions could you please share some books or tutorial documents about pyqgis

  • @priyasofy6652
    @priyasofy6652 3 года назад +1

    Great info. Proximity analysis can be done using this easily.

    • @msrgeospatialsolutions
      @msrgeospatialsolutions  3 года назад

      Thank you for comment priya.. Yes, buffer can be done for any feature type. It may be useful as per requirement.

  • @hemanthkumar3396
    @hemanthkumar3396 4 года назад +1

    Very good information. Nice presentation.

  • @aswinib9888
    @aswinib9888 4 года назад +1

    Very good information. Really useful for me. Thank you for it

  • @akbarvalishaik3309
    @akbarvalishaik3309 3 года назад +1

    Thank you for this. Please provide more videos using python in qgis.

  • @rameshrao3740
    @rameshrao3740 3 года назад +1

    Very useful Info.

  • @dr.r.chandrasekharreddy4696
    @dr.r.chandrasekharreddy4696 4 года назад +1

    Wow super sir

  • @ata1088
    @ata1088 3 года назад +1

    Very nice! I am looking forward to see more Python and QGIS related videos.

  • @shiningyang4354
    @shiningyang4354 2 года назад +1

    Awesome video - indeed helpful! also do you know what parameter to change if I wanna create square buffers instead of circles? Thanks!

    • @msrgeospatialsolutions
      @msrgeospatialsolutions  2 года назад

      Thank you for the comments. I will let you know the details, if possible. Keep follow for the updates.

  • @devakithankam
    @devakithankam 4 года назад +1

    Python is in add in plugs??

    • @msrgeospatialsolutions
      @msrgeospatialsolutions  4 года назад +1

      Yes, Python is inbuilt in the form of python console in both QGIS and ArcGIS.

    • @apamwamba
      @apamwamba 9 дней назад

      @@msrgeospatialsolutions is this running in version 3.30.2-'s-Hertogenbosch?