Saturday, June 14, 2008

Ten years

Last Saturday was the commencement of NTU. 恩慈 asked to have a picture with me since she can be one of the first students under my advise. I suddenly realized that this is the tenth year from my college graduation from NTU. Ironically, It was impossible for me to foresee that I can be still in the same campus after 10 years. Maybe I am a very lucky guy.
Ten years, I have visited so many places more than I expected then. I even went aboard to complete a PhD degree which is out of my plan 10 years ago. Ten years everything is different from my expectation ten years ago. I do not know where or who I am ten years later. I can say that I have a fruitful trip in the past ten year and I hope I can keep up my young spirit for me to have more adventure trips.

Friday, June 13, 2008

More SEKS-GUI

1. Clustering analysis
  • to identify the attribute clustering
  • to identify the data location clustering
2. SEKSGUI website
  • Memebership to create the listing of users
  • Update users about SEKSGUI news
3. SEKSGUI manual
  • Rewrite an up-to-date manual for SEKSGUI

Sunday, May 4, 2008

New dress for my vista

Poor performance is always an notorious issue for Vista. Today during my routine search for the new trick to boost my vista, I accidently run into the theme transformation of my Vista. Finally I made it into a Mac-looking vista. The new outlook is pretty and I am still enjoying its new dress.
Here is the steps that I had followed
  1. Download and Install VistaOSX program
  2. Type msconfig at startup and then uncheck RK Lanucher and leftsider in the startup tab
  3. Download and install objectdock program, which I feel is the the better dock program for Vista
Note: RK Lanucher is a dock program for vista and lefsider is the program to change the control of the windows from upper-right corner to upper-left corner. Both of these programs are integrated within the VistaOSX package.

Thursday, March 27, 2008

UTM Projections

About the zoning of UTM coordinate systems, here I attach the UTM zone for Taiwan
Taiwan
WGS72
UTM Zone 50N
UTM Zone 51N
WGS84
UTM Zone 50N
UTM Zone 51N

Wednesday, March 26, 2008

Projection transformation

It has been confused me for a while. How to define or transform the projection of a shapefile in ArcGIS such that it can align with other maps with different coordinate system. Here is the steps in ArcGIS 9.X.
  1. Figure out the original projection of your map even though it has not been defined before, namely it does not have any projection file (*.prj) along with other files for shapefile.
  2. Two coordinate system can be defined in a shapefile, one is geographical coordinate system which is essentially for longitude and latitude; the other one is projected coordinate system which is for the planar coordinate (two-dimension)
  3. To define a coordinate system to a shapefile, Go to ArcToolbox -> Data Management Tools -> Projections and transformations -> Define projection, and then a window will popup for us to select the shapefile (feature class) to define and the coordinate system
  4. To change a coordinate system of a shapefile in order to align with other shapefile,
    1. Determine the coordinate system to which we would like to transform
    2. Go to ArcToolbox -> Data Management Tools -> Projections and transformations ->Feature -> Project
    3. Specify the shapefile to transform (feature class), the name for the new shapefile with new coordinate system (projection), and the new coordinate system in the popup window
    4. OK
  5. The new shapefile will automatically be added into the current project
  6. Note that the table of the new shapefile is exactly the same as the original shapefile. The new geometry values upon the new coordinate system can be generated by adding new field in the Table and do the Geometry calculation.

Saturday, March 22, 2008

Shame on our Taiwanese

Tonight the china goverment has already promote our referendum result to international society that our Taiwanese veto the our own willingness to pursue UN membership. It is a shame. The political parties only want to beat its adversary up and ignore the interest of our entire country. Being in this status, I feel so shame living in such a dissociated country. Everyone is selfish that they only want the victory of their own party no matter if their country is being scarified.

If you are not Taiwanese and see this article, I wish you realize that we really need your help to support Taiwan to join any international community, no matter which news you saw and what interpretation they made. The fact is Taiwan is a new democratic country. Our people are still learning to use our rights to make our own decision. We can be confused by the atmosphere of our internal political status that two parties divide our country for several years and have been fighting each other. Our people can temporarily forget their power to speak out by their votes rather than being like the slaves in the recent movie "10,000 BC" who forget they do have power to change their destiny.


Tuesday, March 18, 2008

對台灣現狀與未來的ㄧ些想法

總統選舉到了,今天有個朋友(Yi-Hsin)來拉票,他是某黨青年團的,也上過政論節目 衝著他可能有管道跟著上頭做決策的人,有ㄧ些溝通,我跟他碎碎念了我的ㄧ些想法,這些想法,在過去幾年,我有時無時地跟著我周遭的人碎碎念過,但好像重來沒有寫下來,今天在這裡也做個記錄,把我這幾年,在美國當無聊留學生時 看著我生長的土地的ㄧ些變化時,想的ㄧ些東西,趁著還沒忘掉時,把他留在這裡。

這幾年台灣的紛紛擾擾,相信大家也知道,不用我贅述,也人怪罪政府做不好 有人怪罪媒體沒大腦,但是台灣其實就是缺了一個夢 1998年,阿扁市長競選口號 "有夢最美 希望相隨",十年了,雖然阿扁沒當上市長,但是也做了一陣總統,我們的夢在哪? 我的朋友們,平均每個人上班到八九點,每天十幾個小時的庸庸碌碌的生活,他們為了圓他們獨自的夢,但是整個國家呢?五年十年後,我們國家在哪? 我們還有沒有國家,有的話,我的國家會是個甚麼樣子? 這個在其他國家不是問題的問題,在台灣,這是個大問題,我們是世界的邊緣,因此我們更需要有夢想的支撐,知道我們的努力,是有一個目標的,有希望的。

民進黨過去幾年來,最最失敗的,就是讓人民沒有希望,姑且不論甚麼原因,讓我們失望,也許有人說是總統貪腐,有人說是政黨惡鬥或媒體亂相,我認為其實大家最憂心的是中國的崛起,他在十年八年前,他不是甚麼重要角色,如今他成為一個世界無法忽視的大國,但是最令人憂心的是,這個大國,在我們的旁邊,而且,他是我們的敵國,並且,他想要併吞我們,而且能力越來越強,機會越來越高,而我們無可奈何。

而面對此一大國,台灣該如何自處,是我認為,在總統級的選舉,候選人該給人民交代的地方,這ㄧ次,兩邊政團 一個說633 兩岸共同市場,一個說幸福經濟,一個以數量化的方式,叫喊一個數字,目標很明確,好像給我們一個願景,但是在台灣旁邊的大國持續強大的狀態下,真的能輕易633 而且進而643 653?? 我們國家方向要如何轉變修正,以因應這種兩岸不對等關係的持續擴大?我不認為是喊價式633能夠解決的,兩岸市場也是把希望寄託到與對方(敵國)談判,這好像不是很負責任的政策,而幸福經濟,我覺得聽起來很幸福,但是內容很空洞,我要怎麼才能感到幸福 聽了幾次政見發表,我也不曉得。

我認為台灣缺的是個願景,台灣未來要是甚麼樣子,我繼續在這土地打拼五年十年後 有可能變成甚麼樣子,候選人們,要給大家一個夢,夢不是錢多少,雖然很多人小時候說我的夢想是成為一個一百萬大富翁,但是我想真正的夢想,是一個腦海中的形像,我的國家,未來是甚麼樣的形狀,候選人沒有給我,但是,我在這裡自嗨 想想說 若我是候選人,我覺得台灣需要甚麼。


(思考一): 產業結構

年冬天某個夜晚,我看著某工商日報的頭條,大意如下 XX公司得到韓國三星大單 大漲 心中溜過一股淡淡地憂傷,十年前,我開始玩股票,我每天也是看我買的公司 是不是有大單 現在也是嗎? 十年前,三星在跟我們台灣的工廠在搶英特爾的單, 現在,我們在跟其他公司搶三星的單,我們常常自豪地說,台灣做的的Notebook佔全球超過二分之一,但是,有多少是台灣的品牌,我們的股王,聯發科,裡頭的員工,人人身價百萬,但是市面上的產品,哪一個是聯發科的品牌,雖然他們常常自豪說,裡頭的晶片的他們的,但是如果別人哪天不用你的晶片呢?

台灣的產業,一直是以依附著世界大國所生存,古時候幫別人代工日常用品紡織品,後來幫人家代工科技用品,做來做去,台灣似乎永遠是世界的零組件中心,而我們也這樣自豪的,甚至新聞局兩三年前還請了比爾蓋茲來拍影片來鼓勵著我們 (註一) 說我們在世界上的重要角色。

這個零組件中心的角色,我們做了好多年,也做得很好,但是如今我們面對一個強國,此國人工比我們便宜,土地比我們便宜,環保標準比我們低,所有一切成本比我們低廉,只差他的技術還輸我們一些,而我們,正在跟這樣的敵人在競爭著 而且廠商們如同散沙的各自努力尋找未來的出入,我們小時候,課本告訴我們,台灣是中小企業為主的國家,中小企業最好的就是他有彈性,而現在他的彈性,讓人感受到 很多是彈到中國創造第二春。

我們常常怪罪國內廠商,不重研發,研發是研發如何cost-down 而非真正的嶄新的創意,我們也許偶而會覺得我們為甚麼都只能當代工中心,也很多人有時不時地跟著我們說,自創品牌的困難,而我個人覺得,這一切都是產業結構的問題,而這個問題,就是我們是中小企業為主的國家,有人說我們有郭台銘、林百里、張忠謀 .... 但請也去數數,我們這個全球第十幾的經濟體,有幾家企業在每年的Fortune 500 ?我也沒仔細數,但是應該是兩三家,最多五六家,排名三四百,而且每年不一定一樣,在世界的尺度,他們一樣是小企業。

中小企業,我們沒有錢跟大廠,打花錢如流水行銷戰,也無法花錢如流水的做不知會不會成功的研發,只能很彈性地做代工搶單戰,而且我們做得很成功,所以中國要學我們,我們能提升的只有技術,或是把廠房移過去降低成本,而我認為,台灣不應該把中國當競爭對手,我們應該要把他當我們的下游,我們要跟韓國一樣 把從接單者的角色,變成發單者的角色,讓未來五年,中國某公司,會因為接到我們某大廠的單,大漲股票三根,而不是我們要接他的單,大漲股票三根。

因此,總統候選人,可以給人民的第一個願景,就是重整台灣產業結構,讓台灣能夠真正地跟世界級企業,來場正規軍作戰,政府為後盾,讓台灣脫離代工中心的角色,如此就可跟中國有所區隔,不怕競爭。


(思考二): 國內產業失衡

媒體天天說台灣是M型社會 我一個在學校當老師的 應該還不算差的工作 我是M的哪一邊? 根據我查的相關資料 我每年零零總總能拿到的薪水加獎金 可能差不多是平均數 或是 M型少的那一邊 這天起來 有些悲哀 怪只怪我當初上大學時 選錯科系

台灣目前社會 出現了極端反常的產業偏差 念某些科系或產業的平均薪水(資訊電機科技業) 遠遠超過念其他領域的薪水(非資訊電機科技業) 而這種產業失衡原因 我觀察的原因是 因為科技業是少數不完全走內需市場的產業換句話說 而越需要依賴府為生的產業 拿政府發包計畫的產業,可能越慘 而其中問題與政府標案橫向連結以及競標對象結構問題,息息相關,

一般政府單位徵求計畫,往往尋求可以提供最少錢,能夠滿足政府需求的單位為主,此所謂最低價標,最低價標沒有錯,他可為政府節省預算,也維持住各投標單位的公平性,但是在投標的單位結構中,往往是包括外頭公司與學校單位一同競爭,而學校單位通常人力以及設備經費需求很低,造成外頭業界需要銷價競標進而得標,一方面造成外頭公司業務量龐大,員工薪水偏低,服務水準粗糙。

另一方面是政府尋求計畫時,橫向整合往往有相當大的問題,舉個例子,先前我有個朋友協助政府機關規劃職前訓練的服務,這樣的服務,教育部、勞委會以及其他單位都有對外徵求,要做一模一樣的事,這種現象透露出政府規劃施政時,均是獨立運作,缺乏橫向溝通,因而預算分割,導致每件事情,都能少少的錢,做少少的事,而且重複沒效率的做,也對未來施政沒什麼幫助,最重要的對外頭做這類事情的產業,一樣需要削價競爭,造成人人沒飯吃,事情沒做好。

一個總統候選人,應該針對產業失衡的問題,調整政府結構,使之更有效率,進而讓政府預算能真正佳惠那些需要以內需市場為生的產業。



(思考三): 台灣的除了科技以外的優勢
這個優勢十年前的現在 比今天更是明顯 而他就是流行文化的優勢 我們近兩三年常常羨慕韓國經濟比我們好等等 其實韓國近年來 真正恐怖的是他的文化產業大量輸出 從野蠻女友開始 我們喜歡他的火花 戀歌 大長今 甚至電影 至於韓國旅遊團 這是文化的優勢 他們從文化輸入國變文化輸出國 而台灣 在華人市場也是一般 先前 我們對全世界華人市場 輸入電視劇 流行音樂 創造無數明星 而這股力量 讓我所認識的中國朋友們 都深深地對台灣這塊土地 有著好奇心
但是我感覺到 我們任由這股力量 慢慢地流失 在近幾年 我們李安拍電影 要去找中國甚至外國出資 我們新秀導演 為了新聞局一百萬爭破頭難出頭 拍出來的片子 甚至沒有電影院或是檔期可以播放 這些是蠻心酸的
我認為一個總統候選人 應該要發下宏願 將台灣打造成華人世界的好萊塢以及流行文化中心 讓台灣能透過這強大的流行文化 主宰全世界華人市場流行圈 進而利用文化優勢行銷將台灣的所有產業推出去

(思考四): 台灣的定位與價值
在國外留學幾年間 常常很努力地想要跟外國人說台灣的好 但是從小受中國教育的我 對台灣認知實在有限 但是我又是個死鴨子嘴硬 不太願意台灣跟中國是一樣的傢伙 有一個小故事 讓我印象深刻 我和一個韓國朋友很要好 我又愛吃辣 一個機會下 我跟我朋友說 我好喜歡吃韓國菜 尤其是他們的辣豆腐湯 我那夠義氣的韓國朋友 問了一句我傻住的話 他問我 他也好想找台灣食物吃吃看 但是怎麼找都找不到 我有沒有可以介紹的 我沉默了 因為 我知道有好吃的地方 但那些店 每一家都是掛XX Chinese Gourmet 等等的招牌 沒有一家賣台灣料理的店 會掛上Taiwanese Resteraunt 等類似字眼 雖然我知道 那些開中國餐館的都是台灣人 但這種莫名奇妙的事實 真是難以跟外國人啟齒阿 當然 當然還有外國朋友問 台灣有甚麼好玩 有甚麼特殊 ..... 他們想知道 而這些都是讓我這自以為台灣人的人 很難回答
我思考著台灣的特殊性 我思考著台灣人跟中國人的差別 除了我們民主 他們獨裁 還有甚麼差別 我們拿甚麼去吸引世界的眼光 身為台灣人的我 都知道台灣的好 但他好在哪 我講不出個所以然 他是我生活的一部分 我活得很自然 但是我不知道怎麼去跟外國人描述
思考著台灣的歷史 跟台灣的地理 以及觀察著我生活在美國與台灣的對比 我察覺到一個我們台灣需要走的方向 而我認為一個總統候選人 也應該要有這種理想 也就是打造台北 甚至台灣 成為東亞的紐約 甚麼叫作紐約 就是一個各種文化匯集多元的地方 我們有中國各省 有日本 一條街上 有中國菜有日本料理 又義大利麵 而我們需要更有胸襟的移民政策 打造台北台灣成為一個亞洲獨一無二東亞的明珠 這種概念 就完全跳脫我們老是眷戀著我們有中國五千年歷史的扭曲感覺 當然 現在 離這目標還很遠 因此 台灣 需要往這裡前進 取代已經被中國占領的香港 成為新的東方之珠

(思考五): 高等教育
台灣的大學有一個問題 跟歐美比較 就是走在校園裡 外國人沒幾個 外國學生不多 外籍老師更少 這個對於有五年五百億預算 目標是全世界百大的台灣的學校擠進 在先天的條件上 就是很local 一點都不世界級 為什麼 我認為 是我們薪水制度出問題 兩年前這個時候 想申請台灣最好的大學的職位 請了一位世界級知名的學者幫我寫推薦信 那位學者很熱心地幫我去該系網站看了一下公告 發現招募的不只一人 他也動心了 為什麼 他是一位在美國已經退休的知名教授 但是他也一直在世界各國繼續游走研究及講學 這是我觀察美國很多老師的行徑 他問我說 台灣薪水怎麼樣 若有機會他想來看看 我努力地查了國科會以及政府網站能夠付給他的薪水 他看完 就說謝謝在聯絡 專心幫我寫推薦信 ..... 我知道我們定的價格 實在是低的很好笑 類似的例子 也發生在我知道的系所 招募一位外籍老師上 他開心地來報到 然後聽到薪水 馬上落跑 ......
我們是個類似資本主義的社會 但是在學校裡 我們發的是共產主義的薪水 目前我們有五年五百億 給老師的獎勵並不是用高心去挖腳優秀的人才 而是用績效獎金的方式 去獎勵好的人 這個差別就像經營職棒 美國職棒跟中華職棒的差別 美國職棒用簽約金吸引優秀的人進來讓他無後顧之憂 中華職棒壓低本薪及績效獎金的方式 鼓勵球員 那我們應該看出高下了 而台灣經營高等教育的方式 就像是經營中華職棒一樣 導致老師們生活不安穩 能力強薪水低 所以到處兼差 學術氣氛低迷 甚至影響外頭的產業
而研究能力 是一個國家的強弱指標 對台灣內部產業的發展 也有帶動的作用 台灣應該在本質上 經濟上做轉型 才能廣收外國人才 對國內研究環境產生質變 進而真正走向世界級

(思考六): 移民問題 -- 大陸新娘
台灣的移民政策 很怪 雖然我不是外籍 但我深深感覺我們歧視外國人 國內氣氛也是 我們稱菲律賓人菲傭 泰國人泰勞 等等 這些字眼或多或少帶著歧視的意味 進而阻擋台灣成為一個真正多元文化交流的環境 而大陸新娘有甚麼好講的 因為他特別地受歧視

(續...)



註一: http://www.youtube.com/watch?v=luiMCMJDbB4
註二: https://www.cia.gov/library/publications/the-world-factbook/geos/tw.html

Monday, March 17, 2008

Collected GIS lectures

  1. Introduction to GIS by Dr. Kumar in Dept of Ecosystem management in U of New England, AU
  2. GIS I: by Dr. Duh in Dept of Geography in Portland State University, USA with textbook Geographic Information Systems and Science by Drs. Longley, Goodchild, Maguire, Rhind
  3. GIS application II by Dr. Duh in Dept of Geography in Portland State University, USA

Friday, March 14, 2008

To adjust the position of maps in ArcGIS

Here I encounter an interesting problem that two Taiwan shapefile with two different administrative units can not completely overlay to each other (shown in the first figure below). It confused me a lot and made me think that the projection definition can be an issue for these maps. Some solution for the change of projection system in ArcGIS is discussed in this document. The projection definition indeed has some issue in Taiwan area where several definitions exist concurrently and are inconsistent. For the detail information about the projection issue in Taiwan.
  1. Introduction to projection system and definition of two-degree transverse Mercator (二度分帶)
  2. The webpage for the description the three common Transverse Mercator system TWD67 (Taiwan Datum 67), TWD97 (Taiwan Datum 97), WGS84 (World Geodetic system 84)
  3. A very informative educational website
  4. Projection system transformation
However, in fact, the solution of the displacement of these two shapefiles in ArcGIS does not have anything to do with the coordinate systems, according to the experience drawn from the trials by myself and my student. Here is the solution to adjust the map proposed by Chi-Shih
  1. 開啟arcmap選擇a new empty map
  2. 看到一個黃色+號圖形,把這三張圖讀出
  3. toolseditor bars→會出現編輯的工具列
  4. editorstart editing→就可以開始編輯
  5. 先打勾里村跟縣市(或鄉鎮)作對比
  6. 看完對比之後,只那村里勾選→用滑鼠把外島那一部份框起來,移至最左邊,不要擋到其它那兩張圖外島的位置就行了
  7. 然後勾選其它兩張任一張圖,做對比→一一的移動到適當的位置
  8. 完成了之後,到editorstop editing→它會問要不要存檔→ok→即完成


Friday, March 7, 2008

Goodbye! my first home Apt 42
















Apt 42 ... I almost forget and tried very hard to recall this number. Tomorrow everything will be moved out from there. Just write it down here to memorize the days I was there. The flowers were from Taiwan and came along with me across the US continent from Chapel Hill to San Diego and finally grew up at Apt 42. The other one is my corner where I work, eat, watch youtube, and spend the time when I was suffered.





Thursday, March 6, 2008

Sluggish youtube at your home !!??

I have been suffered by sluggish youtube transfer speed since long time ago. The slow internet speed stops me enjoying many internet video service which I had enjoyed when I was in San Diego. Today I finally identify the cause of this serious difficulty. That is "Hinet". I still do not know why the internet service from our greatest communication company in Taiwan has such a poor quality. Setting a internet proxy in your browser can be a solution to avoid the direct internet transfer through the poor hinet network.

Tuesday, March 4, 2008

June

I like this song. This song makes me recall so much. I miss the time I was in San Diego. Even though I moved out from there several months ago, it is still sad for me to hear that the story in that warm and lovely place is going to the end. So much to be memorized, just use this song at this little place to express my feeling.


Get this widget | Track details | eSnips Social DNA

Monday, March 3, 2008

A lonely position

I can not say my job is bad. It is free, very free. I can do whatever I want during the working hours. I can sleep a late as I want. I can even not go to the office. I can go aboard several times a year. I have long winter and summer vacations during which I can plan anything I like. I can do anything as long as I can pass the university evaluation or I can finish all the works I have promised. I can have my own employees to ask them to do things I like to do. Probably I am having one of the best positions in Taiwan as long as you like research.
Two disadvantages, the first is the low-pay given the responsibility I have to carry. The disadvantage I concern the most is I am lonely, very lonely. I am alone for almost all day long, all week long. I do not have officemates to chat. People I met are my students or my teachers. I can hardly meet somebody who can chat and share with me. Today I am depressed. I am lonely even though many tasks are stilling waiting for me.

Feelings under an arch of triumph

Yesterday I was standing in front of an arch of triumph. No other reasons, just waiting for somebody about 1 hour. After that, I went back to my office directly and resume my heavy tasks.
For what reason, probably I was there to memorize all the good time I had been with her. Even though it must be a no-future relationship, I still appreciate very much all this short time her lovely company. Everything I had done to this relationship was bad because of the diverge of our future plan. Anyway, I wish all her best.




It was a relationship that I hesitate to join because of her status of applying study aboard. In fact, I am looking for a stable relationship to complement my life. It is so obvious that our future plan might not be able to converge given this situation unless she changes her mind.
It is still difficult for me to realize the fact that our very-short relationship has been broken. Though no future, we still share quite a bit happy time together.

Monday, February 18, 2008

Extract points from polyline in ArcGIS

Here is a visual basic macro for ArcGIS to generate points on the polylines. How to use these codes. Few steps are discussed below:
  1. Add the polyline shapefile in your ArcMap project.
  2. Create a point shapefile in ArcCatalog by right-click a specific folder and select New to create a new point shapefile in which the to-be-generated points will be saved.
  3. In ArcMap, Go to Tool > Macro > Visual Basic Editor > Project > ArcMap Objects > ThisDocument
  4. Copy the VB script attached below and paste into ThisDocument
  5. Highlight the polyline shapefile to be extracted
  6. Click the "Run Sub" button to execute the script
  7. Done !!
----------------------------------------------------
Public Sub CreatePointsAlongCurve()
'Creates points at a set distance along any feature implementing ICurve
'
'Justin Johnson
'January 23, 2004
'justin.johnson@geog.utah.edu
'
'Obtains selected features from currently-selected Layer
'Stores new points in point theme at top of TOC

Dim pMxDoc As IMxDocument
Dim pMap As IMap
Dim pInGeometry As IGeometry
Dim pInLayer As ILayer
Dim pInFLayer As IFeatureLayer
Dim pOutFLayer As IFeatureLayer
Dim pInFCursor As IFeatureCursor
Dim pOutFCursor As IFeatureCursor
Dim pOutFBuffer As IFeatureBuffer
Dim pInFClass As IFeatureClass
Dim pOutFClass As IFeatureClass
Dim pSelSet As ISelectionSet
Dim pFSelection As IFeatureSelection
Dim pInFeature As IFeature
Dim pCurve As ICurve
Dim pPointCollection As IPointCollection
Dim pConstructMultipoint As IConstructMultipoint

Set pMxDoc = ThisDocument
Set pMap = pMxDoc.FocusMap
Set pInLayer = pMxDoc.SelectedLayer

If pInLayer Is Nothing Then 'Check if no input layer is selected
MsgBox "Select a feature layer in the TOC", vbCritical, "Incompatible input layer"
Exit Sub
End If

If TypeOf pInLayer Is IFeatureLayer Then 'check if selected layer is a feature layer
Set pInFLayer = pMxDoc.SelectedLayer 'set selected layer as input feature layer
Else
MsgBox "Select a feature layer in the TOC", vbCritical, "Incompatible input layer"
Exit Sub
End If

Set pOutFLayer = pMap.Layer(0) ' set top layer in TOC as output feature layer
Set pInFClass = pInFLayer.FeatureClass
Set pOutFClass = pOutFLayer.FeatureClass

If Not pOutFClass.ShapeType = esriGeometryPoint Then 'check if output layer is Point type
MsgBox "Geometry type of output layer is not Point", vbCritical, "Incompatible Output Layer"
Exit Sub
End If

'Get selected features, if any
Set pFSelection = pInFLayer
Set pSelSet = pFSelection.SelectionSet

'Prompt user for distance between points
Dim pPointDist As Double
pPointDist = InputBox("Distance between points: ", "Point Spacing in Map Units")

'Create an Insert cursor on output feature class
Set pOutFBuffer = pOutFClass.CreateFeatureBuffer
Set pOutFCursor = pOutFClass.Insert(True)

If pSelSet.Count <> 0 Then
'use selected features from input feature class
pFSelection.SelectionSet.Search Nothing, True, pInFCursor
Else
'use all features if none are selected
Set pInFCursor = pInFClass.Search(Nothing, True)
End If

Dim k As Long 'count the number of points created
k = 0

Set pInFeature = pInFCursor.NextFeature

Do While Not pInFeature Is Nothing

Set pInGeometry = pInFeature.Shape
Set pCurve = pInGeometry
Set pConstructMultipoint = New Multipoint

pConstructMultipoint.ConstructDivideLength pCurve, pPointDist

Set pPointCollection = pConstructMultipoint

Dim i As Long
For i = 0 To pPointCollection.PointCount - 1

Set pOutFBuffer.Shape = pPointCollection.Point(i) 'store the new geometry
pOutFCursor.InsertFeature pOutFBuffer
k = k + 1

Next i

Set pInFeature = pInFCursor.NextFeature

Loop

pMxDoc.ActiveView.Refresh
MsgBox k & " points created in " & pOutFLayer.Name, vbInformation, "Complete"

End Sub

Saturday, February 16, 2008

Compile Fortran and C++ together under VS2005

Since the new release of windows vista system, the old mixed-language programming under WS6.0 and Compaq Fortran 6.0 does not work anymore since both compilers are not compatible with the new windows OS system. In order to response to such changes, here I did my first test of the mixed-language programming under VS2005 and Intel Fortran. The example codes are copied from the website. It should be noticed that the calling convention between Compaq Fortran 6.0 and VS6.0 is different from that between Intel Fortran and VS2005. Here is a table shown in Steve's article "Porting applications from Compaq frotran to Intel Fortran" to list the difference calling conventions.



Therefore, in Intel Fortran, we no longer require the __stdcall put ahead of the fortran functions in the C code. Instead, __stdcall should be replaced by __cdecl or simply be removed. The original codes in the website become

(1) The C++ file:

// This illustrates how a Fortran routine and function may be
// called from a main program in C++
#include
extern "C"
{
void FR1(int*,int *);
int FF1(int *);
}
int main()
{
int n=10,nSq,nCube;
FR1(&n,&nSq);
cout << "The square is:" << ncube="FF1(&n);" style="font-weight: bold;"> (2) The Fortran File:

SUBROUTINE FR1(N,M)
C COMPUTES THE SQUARE OF N, RETURNS IN M
M=N*N
RETURN
END
C
INTEGER FUNCTION FF1(N)
C COMPUTES THE CUBE OF N
FF1=N*N*N
RETURN
END

To build mixed-language the VS2005 project, it is not similar to what we did in VS6.0 where we put both C++ files and fortran files in the same project and then compile them together as a whole. In VS2005, we should separate them into two projects, one for C++ and one form Fortran.
  1. Create a static library package for Fortran files by File > New> Intel Fortran > Library > Static Library when creating the package.
  2. Create a Win32 console application package for C++ files by File > New> Visual C++ > Win32 console application
  3. Create a VS2005 solution by going to File > New > Other Studio solutions > VS solution and add both created packages in.
  4. Add the Fortran and C++ into their packages respectively.
  5. Right-click both packages to confirm their runtime libraries are consistent. For C++, it is at Property > C/C++ > Code Generation > runtime library. For Fortran, it is at Property > Fortran > Libraries and also make sure that "Disable OBJCOMMENT ....." is set to be NO
  6. Add the new created lib file (from the Fortran package) into the solution by add the Fortran package name (FortranName.lib) at Property > Linker > Input > Additional dependence by right-click the C++ package
  7. Add the additional library path for C++ package by going to Tools > Options > Projects and Solutions > Library files and click the white boards to add Intel Fortran library at \IntelFortranRoot\Compiler\Fortran\versioncode\IA32\Lib and the location where the new lib file is generated.
  8. After all these settings, I successfully my first package built under VS2005.

Tuesday, February 12, 2008

Load DEM into ArcGIS

I download the DEM (Digital Elevation Model) files from Geocommunity to do the exercise of Archydro model to analysis DEM file for the collection of geographical information. Geocommunity is the free port providing the free GIS files from all over the world. Its format of DEM files is SDTS (Spatial Data Transfer Standard). In order to transfrom the SDTS file into the suitable format for ArcGIS 9.2 use, we should add the new extension by going to ArcCatalog->Tools-> Customize-> Arcview 8x tools.
The transformation of SDTS file to Grid file for the DEM analysis, it follows the steps
  1. Open ArcToolbox
  2. Under Conversion Tools > Import to Raster, choose 'SDTS Raster to Grid'
  3. In the Input Prefix box, navigate to the folder with the ****.ddf files, and choose the 4 digit input file (ex:1158). Note that the path for the .ddf files may not contain any spaces.
  4. Choose the Z-value field name for the Record No. box, i.e. "ELEVATION".
  5. Select an output folder and name the Grid.
  6. Keep Convert Values and Use Data Dictionary checked.
  7. Hit OK.
  8. You may then add this DEM Grid to ArcInfo Desktop or ArcView 3.x
For more comprehensive information, we can go to the website.

Monday, January 14, 2008

For her

It was long. I do not come here to write and read, since I came back from Taiwan. I was stuffed by all kinds of things and forgot to stop and check myself out. These days, these two weeks, it is hard, not for me, but for her.
這種感覺是辛酸的. 我是個糟糕透的人. 他說不要認為他可憐. 他會比以前更好更美不需要任何人同情. 他是堅強的. 而相對的我是軟弱的. 電話那頭激昂著講著. 而我這頭無言地不知如何答話. 顯地我好冷漠. 但我好難過. 我不知道該怎麼說. 我知道我的錯. 我卻是無法如他那般地堅強地為他的選擇而堅持. 是因為我無法做到他那般地肯定. 我心中有著疑惑. 而就任其這樣將他傷了又傷 傷了又傷. 我在他的世界. 我好似多餘地站在旁. 看著他的掙扎與努力. 我心痛但不行動.



詞曲:石裕博

我還是這樣的想像
事實總是多於遐想
你也不用刻意的補償
到現在有或沒有的感傷

可是始終還是這樣
我連掙扎都不想抵抗
躲起來也顯得那麼匆忙
這可不像我應該的模樣

我還是站在了多餘的一旁 無聊的歌唱
我像是一雙多餘的翅膀 不能帶你飛翔
(我也不想飛翔)

是你讓我回到了開場
黑暗就在不遠的前方
時間總是順著它的方向
不是你我就可以阻擋