Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from osgeo import ogr
- shapefile = ogr.Open( "shapfile.shp",1 )
- layer=shapefile.GetLayerByIndex(0)
- count=layer.GetFeatureCount()
- for feature in range(count):
- layer.DeleteFeature(feature)
- ogr2ogr output.shp input.shp -where "FID < 0"
- import shapefile
- r = shapefile.Reader("myshape")
- w = shapefile.Writer(r.shapeType)
- # This line will give us the same dbf schema
- w.fields = r.fields
- # Use the original bounding box as a place holder in the header
- w.bbox = lambda: r.bbox
- w.save("myshape")
- w.bbox = lambda: [0.0, 0.0, 0.0, 0.0]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement