Spatiotemporal Data Visualization (NTU Geographhy)

12. Spatiotemporal Point Observations

r09228001 楊宇翔

A data story about space-time point observations

Requirement: Using appropriate data to create an STFDF object for representing spatiotemporal point observations.

The assignment should include: 1. Visualization outputs: plots/animations 2. Text descriptions (describe the data and plots, your observations, and possible explanations) at least 150 words (in English) or 500 words (in Chinese)

rm(list=ls()) #clear all
gc() #free up memrory and report the memory usage.
##          used (Mb) gc trigger (Mb) limit (Mb) max used (Mb)
## Ncells 470132 25.2    1009825   54         NA   666817 35.7
## Vcells 879382  6.8    8388608   64     102400  1826598 14.0
library(readxl)
setwd("~/Desktop/110-1/110-1 data visualization/w13_Spatiotemporal Point Observations")
d.r=read_excel("suicideRATE_201601to202110.xlsx",col_names = TRUE)
library(sf)
jp=st_read("~/Desktop/碩論_日本青少年自殺空間變異/data/japan_population_shp/jp1741_bothsex.shp")
## Reading layer `jp1741_bothsex' from data source 
##   `/Users/yangyuxiang_1/Desktop/碩論_日本青少年自殺空間變異/data/japan_population_shp/jp1741_bothsex.shp' 
##   using driver `ESRI Shapefile'
## Simple feature collection with 1741 features and 30 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: 122.9339 ymin: 24.04562 xmax: 153.9867 ymax: 45.52638
## Geodetic CRS:  JGD2011
library(dplyr)
jp=left_join(jp,d.r,by="code")
tokyo=jp[which(jp$prfct__=="東京都"),]
tokyo=tokyo[-c(54:62),]
plot(tokyo["mncpl__"],main="Tokyo City, Japan")

Turn the centroid of polygon with data to Polypointdataframe

library(dplyr)
#install.packages("purrr")
library(purrr)
library(sf)
??st_point_on_surface
?map_dbl
tokyo = tokyo  %>% 
  mutate(lon = map_dbl(geometry, ~st_point_on_surface(.x)[[1]]),
         lat = map_dbl(geometry, ~st_point_on_surface(.x)[[2]]))

library(sp)
class(tokyo)
## [1] "sf"         "data.frame"
d.tokyo=st_drop_geometry(tokyo)
coordinates(d.tokyo) <- ~ lon + lat
proj4string(d.tokyo) <- CRS("+proj=longlat +ellps=WGS84")
plot(d.tokyo)

plot(tokyo$lon,tokyo$lat,col="darkred")

# Turn into STDF

# deal with time variables
library(zoo)
library(reshape2)
library(spacetime)
library("readxl")
setwd("~/Desktop/110-1/110-1 data visualization/w13_Spatiotemporal Point Observations")
d.r=read_excel("suicideRATE_201601to202110.xlsx",col_names = TRUE)
library(dplyr)
d.r=d.r[which(d.r$prefecture_kanji=="東京都"),]
d.r=d.r[-c(54:62),]
library(dplyr)
t.r=d.r[,-c(2:7,78,79)]
t.r=as.data.frame(t.r)

t.r=t(t.r)
colnames(t.r)=t.r[1,]
t.r=as.data.frame(t.r)
t.r=t.r[-1,]
t.r$time=rownames(t.r)    

library(lubridate)
t.r$time=parse_date_time(t.r$time, "ym",tz = "Japan")
t.r$time=as.character(t.r$time)
t.r$time=as.Date(t.r$time)

rownames(t.r)=as.Date(t.r$time)
#t.r=as.data.frame(t(t.r))
#t.r=t.r[-nrow(t.r),]


t.r[, c(1:53)] <- sapply(t.r[,  c(1:53)], as.numeric)

tokyo.zoo=zoo(t.r[,-ncol(t.r)], t.r$time)
dats=data.frame(vals = as.vector(t(tokyo.zoo)))

# creating STFDF object
tokyo.stfdf <- STFDF(sp = d.tokyo,
               time = index(tokyo.zoo),
               data = dats)
# Graphics with spacetime
airPal <- colorRampPalette(c('springgreen1', 
                             'sienna3', 
                             'gray5'))(5)

tokyo.stfdf1<-tokyo.stfdf[, 49]
#tokyo.stfdf1$vals=as.numeric(tokyo.stfdf1$vals)


# single time period
spplot(tokyo.stfdf1,
       cuts = 5,
       col.regions = airPal,
       main = 'Suicide Rate in Tokyo in Oct, 2021',
       edge.col = 'black',
       cex=1.5,
       scales=list(draw=TRUE),
       )

#fig.width=14,fig.height=10
# Graphics with spacetime
airPal <- colorRampPalette(c('springgreen1', 
                            'sienna3', 
                             'gray5'))(5)

# multiple time periods
stplot(tokyo.stfdf[,55:60],
       cuts = 5,
       col.regions = airPal,
       main = '',
       cex=1.0,
       edge.col = 'black')

## adding base map
#install.packages("ggmap")
library(ggmap)
gmap = get_map(tokyo.stfdf1@bbox)

box <- tokyo.stfdf1@bbox
midpoint <- c(mean(box[1, ]), mean(box[2, ]))
long.center <- midpoint[1]
lat.center <- midpoint[2]
height <- box[2, 2] - box[2, 1]
width <- box[1, 2] - box[1, 1]

sp.basemap <- list("grid.raster", gmap, 
                   x = long.center, 
                   y = lat.center,
                   width = width,
                   height = height, 
                   default.units = "native", 
                   first = TRUE)

stplot(tokyo.stfdf[,51:54],
       cuts = 5,
       col.regions = airPal,
       main = '',
       cex=1.5,
       edge.col = 'black',
       sp.layout = sp.basemap)

stplot(tokyo.stfdf[,55:60],
       cuts = 5,
       col.regions = airPal,
       main = '',
       cex=1.5,
       edge.col = 'black',
       sp.layout = sp.basemap)

Interpretation :

The figures show the suicide rate spatial distribution in Tokyo city, Japan from March, 2020 to December, 2020. COVID-19 outbreak began in March, 2020 and still happening. We can view March-June, 2020 as the 1st wave of virus outbreak and July-December, 2020 as 2nd wave of virus outbreak. As we can see in the figure, the suicide rate is the highest in the west and middle tokyo in the first wave and there are some place in the DOWNTOWN tokyo begin to possess high suicide rate in the 2nd wave.

This is an intriguing discovery. The suicide rate hotspot (high value location) shift along with the different stage of pandemic. In COVID-19 cases in Tokyo city, Japan, the suicide rate hotspot expand from ruralTokyo (east and middle Tokyo) to urban, downtown Tokyo (west and harbor area). This phenomen may be explained by the the possibilitythat the downtown is more affected by COVID-19 due to high population density.

The End

Thank you for reading