1 | """ |
---|
2 | Convert Continental Slope Survey data from lat/long to easting/northing |
---|
3 | and ensure elevation data is negative! |
---|
4 | |
---|
5 | Jane Sexton Dec 2006 |
---|
6 | """ |
---|
7 | |
---|
8 | def alter_file(filename,filenameout): |
---|
9 | |
---|
10 | from anuga.coordinate_transforms.redfearn import redfearn |
---|
11 | |
---|
12 | fid = open(filename) |
---|
13 | lines = fid.readlines() |
---|
14 | fid.close() |
---|
15 | |
---|
16 | fid_out = open(filenameout, 'w') |
---|
17 | for line in lines[1:]: |
---|
18 | fields = line.split(',') |
---|
19 | x = float(fields[0]) |
---|
20 | y = float(fields[1]) |
---|
21 | zone, easting, northing = redfearn(x,y) |
---|
22 | z = -float(fields[2]) |
---|
23 | s = '%f,%f,%f\n' %(easting,northing,z) |
---|
24 | fid_out.write(s) |
---|
25 | |
---|
26 | fid_out.close() |
---|
27 | |
---|
28 | return |
---|
29 | |
---|
30 | import project_slide |
---|
31 | |
---|
32 | filename1 = project_slide.datadir + 'yxz_Area_A_LL_100mInterp.xya' |
---|
33 | filename2 = project_slide.datadir + 'yxz_Area_B_LL_100mInterp.xya' |
---|
34 | filename3 = project_slide.datadir + 'yxz_Area_C_LL_100mInterp.xya' |
---|
35 | |
---|
36 | filenameout1 = project_slide.datadir + 'surveyAreaA.xya' |
---|
37 | filenameout2 = project_slide.datadir + 'surveyAreaB.xya' |
---|
38 | filenameout3 = project_slide.datadir + 'surveyAreaC.xya' |
---|
39 | |
---|
40 | files = [filename1, filename2, filename3] |
---|
41 | fileouts = [filenameout1, filenameout2, filenameout3] |
---|
42 | |
---|
43 | for i, eachfile in enumerate(files): |
---|
44 | print 'File ', i, eachfile |
---|
45 | alter_file(eachfile,fileouts[i]) |
---|