# 生物地圖 2021 圖資轉點位流程文件
###### tags: `NGIS團隊工作事項總目錄`
:::info
更新日期:2022-01-13
更新人員:吳俊毅
建立日期:2022-01-03
建立人員:吳俊毅
:::
:::warning
README
* 本文件說明將圖資轉為點位型資料方法
* 本文件所屬目錄:[NGIS團隊工作事項](https://hackmd.io/SVhKwMMzSkWZMY9Z8XOjCA?view)
* 關於生物地圖在OP v2.0查詢行為討論請見:
[OP生物分布圖層](https://hackmd.io/@JunyiWu/SyIdSZ2St)
[生物地圖](https://hackmd.io/@jeromeko/rk35vkh7U)
* 生物地圖更新流程文件:
[生物地圖 updatae version2](https://hackmd.io/wPzG0dReSzikhBsv_RnTUw?view)
:::
## 簡介
本文件目的,為將姿蒨過去製作的鳥類、哺乳類、兩棲類以及爬蟲類總共684張(原有689張,但有5個分類群尚未處裡)「專家意見海拔縣市範圍圖」或「專家意見海拔分布圖」,以及棲地組同事(宛均、小蟲)所製作的49種陸域脊椎保育類動物潛在分布範圍圖共49張,重新轉製成能讓[TBN2.0](https://www.tbn.org.tw/)能夠讀取的點位資料。
## [流程圖](https://drive.google.com/drive/folders/16Q-1g9WueYhSqavnc6L8RYlvuDE8FZ2F)

## [file download](https://drive.google.com/file/d/1mW1cPBnY7Ar12E718_BkeLC5ldvhof64/view?usp=sharing)
* input
* data:
* metadata_raw.csv
* 20211103 TTsplist.csv
* polygon
* TBN WGS84 gird:grids_4326_1km_land.shp
* 49種陸域脊椎保育類動物潛在分布範圍:protected_rangemap_20200512.shp
* 專家意見海拔分布範圍圖:folder→prof_map
* processing
* 初次比對無法對到物種圖層清單:undefine_aves, undefine_mammals, undefine_reptile, undefine_amphibian
* 二次比對無法對到物種圖層清單:undefine_taxon2
* 人工比對清單:undefine_mammal_check_by_junyi.csv, undefine_taxon2_check_by_ming.csv
* 比對完整清單:
* prof_map:prof_map_to_grid
* range_map:range_map_to_grid
* output
* prof map
* prof_map_metadata.csv
* prof_map_gird.csv
* polygon:所有prof map 原檔重新命名儲存
* range map
* range_map_metadata.csv
* range_map_girdcoor.csv
* polygon:49種陸域脊椎動物網格圖層
* TBN_grid
* 4326_grid_point:grid_land_point_4326_1km.shp
* script:
* M5.1 transform to gridlist.r
* M5.2 coordnate grid to edge poin or center.r
## meta data & point table perpare
### meta data table
* 確定圖層meta data欄位資料內容
* result:input\\data\\metadtat_raw.csv
* summary:5種圖層類型的metadata(49種陸域脊椎動物潛在分布圖、鳥類+哺乳類+爬蟲類+兩棲類專家意見圖層)
* columns:`class`, `上線日期`, `更新日期`, `圖資版本`, `建立方法`, `類別`, `適用的時間範圍-起`, `適用的時間範圍-迄`, `解析度`, `圖資開放與否`, `是否為建議圖層`, `說明文件網址`, `建議引用方式`, `備註`
* rows:5
### polygon list with meta data table
* 將圖層轉為清單,與TTsplist以學名對應出每張圖層分類群的taxonUUID。初次未比對到taxonUUID的物種撇除哺乳類,再以別名作二次比對。二次比對仍沒有taxonUUID物種與哺乳類未比對到的物種則採用人工比對。比對到taxonUUID同時,產生mapUUID,並補上meta data table
* result:
* output\\prof_map\\prof_map_metadata.csv
* output\\range_map\\range_map_metadata.csv
* summary:提供ghtiun加入OP生物地圖介面metadata資料,共49張+684張圖層(5種複合種未上線)
* columns:`taxonUUID`, `mapName`, `mapUUID`, `上線日期`, `更新日期`, `圖資版本`, `建立方法`, `類別`, `適用的時間範圍-起`, `適用的時間範圍-迄`, `解析度`, `圖資開放與否`, `是否為建議圖層`, `說明文件網址`, `建議引用方式`, `備註`
* rows:
* output\\prof_map\\prof_map_metadata.csv:684
* output\\range_map\\range_map_metadata.csv :49
* script:M5.1 transform to gridlist.r
### polygon list create the point table
* 將圖層轉為清單,與TTsplist對應上每張圖層分類群的taxonUUID之後,預先產出包含所有圖資必要資料的清單,方便下個步驟補上點位資料欄位
* result:
* processing\\prof_map\\prof_map_to_grid.csv
* processing\\range_map\\range_map_to_grid.csv
* summary:table須包含物種正確學名、taxonUUID、圖資名、mapUUID,方便之後對應
* columns:`scientificName`, `taxonUUID`, `gridName`, `mapUUID`
* rows:
* processing\\prof_map\\prof_map_to_grid.csv:684
* processing\\range_map\\range_map_to_grid.csv:49
* script:M5.1 transform to gridlist.r
### polygon list to read raw shapefile and rename
* 將圖層轉為清單,與TTsplist對應上每張圖層分類群的taxonUUID之後,重新依據20211103TaxaTree學名作為圖層名稱存檔。
* result:
* output\\prof_map\\polygon\\4個類群共684張圖層
* output\\range_map\\polygon\\49種陸域脊椎動物圖層
* summary:重新以正確學名儲存圖層檔案,方便後續使用圖層不會有檔名問題
* script:M5.1 transform to gridlist.r
## transform grid or polygon to point
### transform TBN OP grid to point
* 將[TBN-OP網格圖層(WGS84格式)](https://github.com/RedbirdTaiwan/TWGrid-WGS84)轉為網格中心點位圖層,便於之後步驟與生物圖層作空間選取套疊。
* result:
* output\\TBN_grid\\4326_grid_point\\grid_land_point_4326_1km.shp
* summary:OP網格(WGS84格式)中心點圖層,每個點包含該網格編號
* script:M5.2 coordnate grid to edge poin or center.r
### transform range map grid to point
* 將49種陸域脊椎保育類動物潛在分布範圍與OP網格中心點位圖層套疊,分別轉出49個物種各自的潛在分布範圍點位座標,點位座標塞入同一個table
* result:
* output\\range_map\\range_map_girdcoor.csv
* summary:必須將49種陸域脊椎動物分成各自網格範圍,再與點位圖層套疊,將所有的點位的經緯座標轉成字串合併,塞入同一個欄位裡面。
* columns:`scientificName`, `taxonUUID`, `gridName`, `mapUUID`, `gridcoordinate`
* rows:49
* script:M5.2 coordnate grid to edge poin or center.r
### transform prof map grid to point
* 專家意見海拔分布範圍圖與OP網格中心點位圖層套疊,再轉出各自分布範圍的點位座標,塞入同一個table
* result:
* output\\prof_map\\prof_map_gird.csv
* summary:將所有專家意見海拔分布圖各自讀取再與點位圖層套疊,各自套疊結果點位再將經緯度座標合併成一個字串,塞入同一個欄位裡面。
* columns:`scientificName`, `taxonUUID`, `gridName`, `mapUUID`, `gridcoordinate`
* rows:684
* script:M5.2 coordnate grid to edge poin or center.r
## Reference
姿蒨TBN Range map github(未開放):https://github.com/oliviakuo/TBN_range_map
49種陸域脊椎保育類動物潛在分布範圍:https://www.tesri.gov.tw/A6_3/content/32654
TWGrid-WGS84 台灣經緯網格系統:https://github.com/RedbirdTaiwan/TWGrid-WGS84