地形データ(鳥取県とその周辺)

raster ,marmap パッケージ

今回は3秒角(約90m)メッシュのSRTM-3データとrasterパッケージを使います。(海底地形のデータはない)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
library(raster)
zipfile=tempfile()
download.file("http://dds.cr.usgs.gov/srtm/version2_1/SRTM3/Eurasia/N35E133.hgt.zip",zipfile)
unzip(zipfile)
t1 = raster('N35E133.hgt')
download.file("http://dds.cr.usgs.gov/srtm/version2_1/SRTM3/Eurasia/N35E134.hgt.zip",zipfile)
unzip(zipfile)
t2 = raster('N35E134.hgt')
#raster::merge関数はfilenameオプションで保存もできる
tottori<-merge(t1,t2)
slope <- terrain(tottori, opt='slope')
aspect <- terrain(tottori, opt='aspect')
hill <- hillShade(slope, aspect, 40, 270)
brks<-c(1,seq(100,2000,100))
arg <- list(at=c(0,500,1000,1500,2000), labels=c("0","500","1000","1500","2000"))
#png("tottori001.png",width=1000,height=1000)
plot(hill, col=grey(0:100/100), legend=FALSE, main='Tottori')
plot(tottori,breaks=brks,col=terrain.colors(25,alpha=0.35), add=TRUE, axis.args=arg)
yonago_city<-c(133.331,35.428)
tottori_city<-c(134.235,35.501)
points(yonago_city[1],yonago_city[2],pch=16,cex=0.5, col="red")
points(tottori_city[1],tottori_city[2],pch=16,cex=0.5, col="red")
segments(yonago_city[1],yonago_city[2],tottori_city[1],tottori_city[2],col="red",lwd=1.5)
#dev.off()

1
2
3
4
5
6
library(marmap)
tba<-as.bathy(tottori)
#png("tottori002.png",width=1000,height=1000)
trsect<-get.transect(tba,yonago_city[1],yonago_city[2],tottori_city[1],tottori_city[2],distance = TRUE)
plotProfile(trsect)
#dev.off()