Advertisement
Guest User

Untitled

a guest
Aug 13th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. from osgeo import ogr
  2.  
  3. shapefile = ogr.Open( "shapfile.shp",1 )
  4. layer=shapefile.GetLayerByIndex(0)
  5. count=layer.GetFeatureCount()
  6. for feature in range(count):
  7. layer.DeleteFeature(feature)
  8.  
  9. ogr2ogr output.shp input.shp -where "FID < 0"
  10.  
  11. import shapefile
  12. r = shapefile.Reader("myshape")
  13. w = shapefile.Writer(r.shapeType)
  14. # This line will give us the same dbf schema
  15. w.fields = r.fields
  16. # Use the original bounding box as a place holder in the header
  17. w.bbox = lambda: r.bbox
  18. w.save("myshape")
  19.  
  20. w.bbox = lambda: [0.0, 0.0, 0.0, 0.0]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement