/ Published in: Python

create buffer polygon from shapefile
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#now open the shapefile shp = ogr.Open(shpfile) drv = shp.GetDriver() drv.CopyDataSource(shp, buffile) shp.Destroy() buf = ogr.Open(buffile, 1) lyr = buf.GetLayer(0) for i in range(0, lyr.GetFeatureCount()): feat = lyr.GetFeature(i) lyr.DeleteFeature(i) geom = feat.GetGeometryRef() feat.SetGeometry(geom.Buffer(1000.0)) lyr.CreateFeature(feat) buf.Destroy()
Comments
