-
Notifications
You must be signed in to change notification settings - Fork 0
/
skyview.py
64 lines (41 loc) · 1.03 KB
/
skyview.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# cd /Volumes/Transcend/TerrainParam
# skyview.py kiban50_450F.tif 6
import sys
import numpy as np
import cv2
import terrain_util as ut
#reload(ut)
param=sys.argv
if len(param) != 3:
print " * Usage : skyview.py dem.tif num"
print " num : number of directions"
exit()
dem=ut.read_tif(param[1])
num=int(param[2])
#dem=ut.read_tif('kiban50_450F.tif')
#num=6
sangle=np.arange(num)*360.0/num
print sangle
print ut.dx,ut.dy,ut.imax,ut.jmax
slp=ut.slope(dem)
asp=ut.orient(dem)
ut.asp=asp
ut.coss=np.cos(slp)
ut.sins=np.sin(slp)
if ut.dx != ut.dy or ut.imax != ut.jmax:
print " For dx=dy and imax=jmax only !!"
exit()
ut.dd=ut.dx
sky=np.zeros((ut.jmax,ut.imax),dtype=np.float32)
for angle in sangle:
print '* '+ 'angle='+str(angle)+' *'
sky=sky+ut.sky(dem,angle,2)/num
#print np.max(sky),np.min(sky)
sky[np.where(sky<0.0)]=0.0
#skyx=cv2.resize(sky,(500,500))
#cv2.imshow('sky',skyx)
#cv2.destroyWindow('sky')
ut.write_tif('skyview.tif',sky.astype(np.float32))
exit()