走過大崩壞 為台灣土地把脈01
2010年10月26日 星期二
2010年10月21日 星期四
統計面資料內polygon的網格
我們在使用 ArcGIS時,常用到需要向量式的shapefile和網格式資料要交互分析,例如:一個集水區的平均坡度或平均高程,由於集水區通常為shapefile,坡度圖通常圍網格資料,因此一個集水區通常會包含許多網格資料,要如何去計算最大值、最小值、加總或平均值,這時就需要用到zonal stastics,以下就計算坡單元平均坡度為例,來說明如何使用zonal stastics
1. 開DEM算slope
2.把坡單元也加進來
3.check坡單元欄位中,必須有一個欄位是可以分別每個feature(FID不算),如果沒有,新增一個long integer的欄位,再用field calculator,欄位等於FID即可。
4.zonal
按OK
5.EXPORT
完成
開啟 Table欄位中的mean則代表,平均坡度。
坡向的算法也是類似,但是坡向比較麻煩,因為1度和359應該相似,但是計算出的結果=(1+359)/2 = 180,導致北向坡與坡向變化大的坡有的錯誤,如果懶的時候也是可以這樣算。正確做法要先算出坡向圖後,把角度換成向量ex:(0,-1),去做zonal,再用sin與cos去分辨像現,則可以計算出平均坡向180。
2010年10月13日 星期三
Matlab讀取 txt文字檔, csv, excel
path = 'C:\\'; %設定絕對路徑
%read txt
cwbdata = load(strcat(path, 'cwb_466920_2006.txt'));
%read CSV
cwbdata = csvread(strcat(path, 'cwb_466920_2006.csv'),2,0);
% Matlab 7.0以後才有的功能
%read excel
cwbdata = xlsread(strcat(path, 'cwb_466920_2006.xls'));
%read txt
cwbdata = load(strcat(path, 'cwb_466920_2006.txt'));
%read CSV
cwbdata = csvread(strcat(path, 'cwb_466920_2006.csv'),2,0);
% Matlab 7.0以後才有的功能
%read excel
cwbdata = xlsread(strcat(path, 'cwb_466920_2006.xls'));
2010年10月4日 星期一
[VB6] 讀區資料夾中所有檔案名稱
Private Sub CommandButton1_Click()
ComboBox1.Clear
Dim s As String
s = Dir("C:\*.*")
Do Until s = ""
ComboBox1.AddItem (s)
s = Dir()
Loop
End Sub
ComboBox1.Clear
Dim s As String
s = Dir("C:\*.*")
Do Until s = ""
ComboBox1.AddItem (s)
s = Dir()
Loop
End Sub
2010年9月28日 星期二
Matlab常用的算術函數
Matlab常用的算術函數(Arithmetic functions)
sin(x), cos(x), tan(x)
exp(x), log(x), log10(x)
- round(x) 四捨五入(Rounds a number to the nearest integer)
- ceil(x) 無條件進位(Rounds a number up to the nearest integer)
- floor(x) 無條件捨去(Rounds a number down to the nearest integer)
- fix(x) 往0的方向取最接近的整數,ex: fix(-3.3) = 3.3 (Rounds a number to the nearest integer towards zero)
- rem(x,y) x/y的餘數(The remainder left after division)
- mod(x,y) 也是餘數,但是和rem()的差別在於處理負數有差(The signed remainder left after division)
- abs(x) 絕對值(The absolute value of x)
- sign(x) 判釋正負The sign of x
2010年9月26日 星期日
iRobot 打掃機器人
最近新買一台iRobot 打掃機器人,操作介面非常簡單,只要按下Clean鍵他就會開始打掃,本來擔心他沒辦法房間的角落,經過約50分鐘之後,他已經跑遍我們家的每個地方,掃完之後比我自己跪在地板上擦地還要乾淨。
打掃完後會自己回去休息。
整個家裡都乾乾淨淨,心情也就好了。





