@@ -0,0 +1,1311 @@
+#!/usr/bin/env python%0A#%0A# shp2gen.py%0A# Convert shapefile to arcinfo generate format%0A#%0A# Author: Matthew Perry%0A#%0Aimport ogr, sys%0A%0Aif __name__ == %22__main__%22:%0A    try:%0A        inputFile = sys.argv%5B1%5D;%0A    except:%0A        print %22 usage: shp2gen.py input.shp %3E output.gen%22%0A        sys.exit(1)%0A%0A    # Open dataset and get layer%0A    ds = ogr.Open(inputFile)%0A    layer = ds.GetLayer()%0A%0A    coords = ''%0A    feature = layer.GetNextFeature()%0A    fn = 0%0A    while feature is not None:%0A        coords = '';%0A        geom = feature.GetGeometryRef()%0A        geomtype = geom.GetGeometryType()%0A        if geomtype == ogr.wkbPoint:%0A            coords = coords + str(fn) + %22,%22 + str(geom.GetX(0)) + %22,%22 + %5C%0A                     str(geom.GetY(0)) + %22%5Cn%22;%0A        elif geomtype == ogr.wkbLineString or geomtype == ogr.wkbPolygon:%0A            geom = geom.GetGeometryRef(0)%0A            numpoints = geom.GetPointCount()%0A            coords = coords + str(fn) + %22%5Cn%22%0A            for i in range(numpoints):%0A                coords = coords + str(geom.GetX(i)) + %22 %22 + %5C%0A                         str(geom.GetY(i)) + %22%5Cn%22;%0A            coords = coords + %22END%22%0A        %0A        feature.Destroy()%0A        feature = layer.GetNextFeature()%0A        fn = fn+1%0A        if coords != '':%0A            print coords%0A    %0A    print 'END' %0A    ds.Destroy()%0A

Convert shapefile to arcinfo generate