Posted By

mbsweng2 on 08/10/12


Tagged

gdal


Versions (?)

create buffer using gdal in python


 / Published in: Python
 

create buffer polygon from shapefile

  1. #now open the shapefile
  2. shp = ogr.Open(shpfile)
  3.  
  4. drv = shp.GetDriver()
  5. drv.CopyDataSource(shp, buffile)
  6.  
  7. shp.Destroy()
  8.  
  9. buf = ogr.Open(buffile, 1)
  10. lyr = buf.GetLayer(0)
  11.  
  12. for i in range(0, lyr.GetFeatureCount()):
  13. feat = lyr.GetFeature(i)
  14. lyr.DeleteFeature(i)
  15. geom = feat.GetGeometryRef()
  16. feat.SetGeometry(geom.Buffer(1000.0))
  17. lyr.CreateFeature(feat)
  18.  
  19. buf.Destroy()

Report this snippet  

You need to login to post a comment.