I'm splitting a large shapefile into many smaller ones using ogr.  I'd like to just copy all of the field and layer config information from the original.  Here's how I'm doing it now:

src = ogr.Open('original.shp', 0)
layer = src.GetLayerByIndex(0)
driver = ogr.GetDriverByName('ESRI Shapefile')
ds = driver.CreateDataSource('file1.shp')
dest_layer = ds.CreateLayer('layer1',
                            srs = layer.GetSpatialRef(),
                            geom_type=layer.GetLayerDefn().GetGeomType())
feature  = layer.GetFeature(0)
[dest_layer.CreateField(feature.GetFieldDefnRef(i)) for i in range(feature.GetFieldCount())]


Is there a more succinct way to do this?


Question: How to mount a NTFS USB harddrive to Mac OS X that was unsave removed from Windows?
Answer: You'll have to have a Windows system handy to have unlocked.  That's the only way I've heard of fixing this issue.

On a related note, unsafely removing a drive from MacOS X can lead to locking, for which I could not find a Mac-native solution.  That was hell in a handbasket to fix.