Last change
on this file since 6540 was
3908,
checked in by sexton, 18 years ago
|
adding script for locating indigeneous communities for FESA nominated areas
|
File size:
1.4 KB
|
Line | |
---|
1 | # |
---|
2 | # script to determine which communities are located in study region |
---|
3 | # 31 October 2006 |
---|
4 | # |
---|
5 | |
---|
6 | def community_in_extent(filename,extent,zone,fid_out): |
---|
7 | fid = open(filename) |
---|
8 | lines = fid.readlines() |
---|
9 | fid.close() |
---|
10 | |
---|
11 | line1 = lines[0] |
---|
12 | line11 = line1.split(',') |
---|
13 | for i in range(len(line11)): |
---|
14 | if line11[i].strip('\n').strip(' ') == 'LATITUDE': lat_index = i |
---|
15 | if line11[i].strip('\n').strip(' ') == 'LONGITUDE': lon_index = i |
---|
16 | if line11[i].strip('\n').strip(' ') == 'COMMUNITY': name_index = i |
---|
17 | |
---|
18 | from anuga.coordinate_transforms.redfearn import convert_from_latlon_to_utm |
---|
19 | from anuga.utilities.polygon import plot_polygons, is_inside_polygon |
---|
20 | |
---|
21 | for line in lines[1:]: |
---|
22 | fields = line.split(',') |
---|
23 | point, zone1 = convert_from_latlon_to_utm(latitudes=[fields[lat_index]],\ |
---|
24 | longitudes=[fields[lon_index]]) |
---|
25 | if zone1 == zone: |
---|
26 | v = is_inside_polygon(point,extent,verbose=False) |
---|
27 | if v == True: |
---|
28 | p = point[0] |
---|
29 | s = '%s, %.2f, %.2f\n' %(fields[name_index], p[0], p[1]) |
---|
30 | fid_out.write(s) |
---|
31 | return |
---|
32 | |
---|
33 | import project |
---|
34 | |
---|
35 | filename = project.community_filename |
---|
36 | filename_out = project.community_perth |
---|
37 | fid_out = open(filename_out, 'w') |
---|
38 | extent = project.polyAll |
---|
39 | zone = 50 |
---|
40 | |
---|
41 | community_in_extent(filename,extent,zone,fid_out) |
---|
Note: See
TracBrowser
for help on using the repository browser.