Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import shapefile as sf
- import sys, glob
- #in_file = sys.argv[1]
- ffiles = glob.glob('00*.txt')
- #Shapefile creation
- shp_filename = 'shp//aari_ibgfrc_120_%s.shp' % ffiles[0].split('.')[0].split('_')[-1]
- # create the shapefile
- w = sf.Writer(sf.POLYLINE)
- w.field('Ice_Object_Num','C','40')
- for ifile in ffiles:
- ff = open(ifile,'r')
- lines = ff.readlines()
- ll = []
- for line in lines:
- x0 = float(line.split()[0])
- y0 = float(line.split()[1])
- ll.append([y0,x0])
- w.line(parts=[ll])
- id = ifile.split('.')[0].split('_')[0]
- w.record(id)
- w.save(shp_filename)
- ff.close()
- # create the PRJ file
- prjfn = shp_filename[:-4]
- prj = open("%s.prj" % prjfn, "w")
- epsg = 'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]]'
- prj.write(epsg)
- prj.close()
Advertisement
Add Comment
Please, Sign In to add comment