source: anuga_work/production/pt_hedland_2006/locate_indigeneous.py @ 4423

Last change on this file since 4423 was 4423, checked in by sexton, 17 years ago

updates for export scripts

File size: 1.4 KB
Line 
1#
2# script to determine which communities are located in study region
3# 31 October 2006
4#
5
6def 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
33import project
34
35filename = project.community_filename
36filename_out = project.community_pt_hedland
37fid_out = open(filename_out, 'w')
38extent = project.polyAll
39zone = 50
40
41community_in_extent(filename,extent,zone,fid_out)
Note: See TracBrowser for help on using the repository browser.