In-class exercise 1.

Indicate countries you have visited so far on a world map in the style of the ebola outbreaks example.

[Note] I add the information of visit counts.

Construct the original dataset

      Year          Month              Country   
 Min.   :1997   Min.   : 1.000   Taiwan    :277  
 1st Qu.:2003   1st Qu.: 4.000    Japan    :  4  
 Median :2009   Median : 7.000    Thailand :  2  
 Mean   :2009   Mean   : 6.515    Australia:  1  
 3rd Qu.:2015   3rd Qu.: 9.000    Austria  :  1  
 Max.   :2020   Max.   :12.000    Germany  :  1  
                                 (Other)   :  5  

Plot the map

In-class exercise 2.

Plot places in administratice areas of Taiwan you have visited so far.

Since I have visited every city and county in Taiwan, I group them into ‘Have lived’, ‘Have stayed’, and ‘Have visited’.

Prepare the datasets

Reading layer `TWN_adm2' from data source `/Users/jayliao/Documents/NCKU_108_Course/dataM/data/TWN_adm/TWN_adm2.shp' using driver `ESRI Shapefile'
Simple feature collection with 21 features and 18 fields
geometry type:  MULTIPOLYGON
dimension:      XY
bbox:           xmin: 119.3138 ymin: 21.89653 xmax: 122.1085 ymax: 25.63431
CRS:            4326
 [1] Kaohsiung City Taipei City    Changhwa       Chiayi        
 [5] Hsinchu        Hualien        Ilan           Kaohsiung     
 [9] Keelung City   Miaoli         Nantou         Penghu        
[13] Pingtung       Taichung       Taichung City  Tainan        
[17] Tainan City    Taipei         Taitung        Taoyuan       
[21] Yunlin        
21 Levels: Changhwa Chiayi Hsinchu Hualien Ilan ... Yunlin

In-class exercise 3.

Map an area of Tainan city to include three of your favorite places to eat as landmarks.

Several maps

Great cafe’ for studying


Great brunch restaurants


Great dinner restaurants


Great bars


Display above venues in the single map with different icons labeling different types of venues


HW exercise 1.

Build a thematic plot of the results of Taiwan 2020 presidential election between the DDP and the KMT. The geographical data (maps) for Taiwan can be obtained from DIVA-GIS: Geographic Information System for Biodiversity Research.

Data - Taiwan Administrative units

Source: Taiwan presidential election 2020. Wikipedia.

Prepate the dataset

Reading layer `TWN_adm2' from data source `/Users/jayliao/Documents/NCKU_108_Course/dataM/data/TWN_adm/TWN_adm2.shp' using driver `ESRI Shapefile'
Simple feature collection with 21 features and 18 fields
geometry type:  MULTIPOLYGON
dimension:      XY
bbox:           xmin: 119.3138 ymin: 21.89653 xmax: 122.1085 ymax: 25.63431
CRS:            4326

HW exercise 3.

Download the data for age fisrt have sex across several countries to make the following plot:

Target output

Target output

Load and check

'data.frame':   42 obs. of  2 variables:
 $ Date     : Factor w/ 42 levels "Age of first sex- Australia",..: 14 18 42 19 24 37 16 31 7 22 ...
 $ X1.1.2005: num  17.3 19.8 19.6 19.1 19 18.9 18.6 18.4 18.3 18.1 ...

Visualize

Map

Warning in countrycode(dta_sex$Country, "country.name", "iso3c"): Some values were not matched unambiguously: Global, Serbia & Montenegro
40 codes from your data successfully matched countries in the map
2 codes from your data failed to match with a country code in the map
203 codes from the map weren't represented in your data
Warning in rwmGetColours(colourPalette, numColours): 5 colours specified
and 9 required, using interpolation to calculate colours

This map is driven by the latest version of the dataset. Thus, it is lightly different from the target output.


HW exercise 4.

Download all the files from github (click the downward triangle in the clone or download button in green) for flood in schools in Taipei to replicate the analysis with the markdown file included.

台北市國民小學與中學洪災分析

降雨頻率分析與淹水潛勢是洪災分析重要的資料來源,利用水文分析進行降雨觀測及淹水分析結果,進一步整合社會統計資料,可評估人類社會承受災害的潛在風險。

假設將24小時延時200年重現期降雨的淹水潛勢的深度達50cm以上的區域,定義為「潛在受災區」。

Load the packages and prepare the datasets

OGR data source with driver: ESRI Shapefile 
Source: "/Users/jayliao/Documents/NCKU_108_Course/dataM/exercise_0518/flood-in-school", layer: "flood50"
with 5103 features
It has 5 fields
OGR data source with driver: ESRI Shapefile 
Source: "/Users/jayliao/Documents/NCKU_108_Course/dataM/exercise_0518/flood-in-school", layer: "tpecity_school"
with 198 features
It has 3 fields
Integer64 fields read as strings:  STUDENTS 
OGR data source with driver: ESRI Shapefile 
Source: "/Users/jayliao/Documents/NCKU_108_Course/dataM/data/mapdata201911261001/COUNTY_MOI_1081121.shp", layer: "COUNTY_MOI_1081121"
with 22 features
It has 4 fields

Plot the map with three layers using basic R graph tools

I also try to label the name of the schools which are involved in the risky area. However, the texts of school names are too small to recognize. Some of them even overlap! I then try to use ggplot2 and ggrepel to fix it.


Compute the number of students under the risk

[1] 3722

台北市共有36個中小學在潛在受災區範圍內,同時可能影響的學生人數共為3722名