0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Rで地図を描く【その3: 白地図を修飾する】

Posted at

0. はじめに

シリーズその3では、白地図を修飾することをテーマに次の2つのトピックについてご紹介します。

  1. 白地図にスケールバーを入れる方法
  2. 白地図に緯度経度の軸を入れる方法

1. スケールバーと緯度経度を入れる

1.1 mapsパッケージ

map.axes()というコードを実行することで、緯度経度の軸とラベルを白地図に加えることができます。map.scale()というコードを実行することで、スケールバーを地図に書き込むことができます。スケールバーが海岸線と重なって見にくくなるのを避けるため、x = 135というオプションを追加しました。これは、東経135度の位置にスケールバーを描くことを指定します。

library(maps)
map("world", xlim = c(125, 145), ylim = c(30, 45))
map.axes()
map.scale(x = 135, ratio = F)

スクリーンショット 2021-03-09 15.33.59.png

1.2 rasterパッケージ

axes = Tというオプションを加えることで、緯度経度の軸とラベルを白地図に加えることができます。rasterパッケージでは、scalebarという関数を利用することでスケールバーを地図に書き込むことができます。以下のコードを実行すると、以下に添付した白地図が得られます。

library(raster)
jpnDat <- getData('GADM', country = 'JPN', level = 0)
korDat <- getData('GADM', country = 'KOR', level = 0)
prkDat <- getData('GADM', country = 'PRK', level = 0)
rusDat <- getData('GADM', country = 'RUS', level = 0)
chnDat <- getData('GADM', country = 'CHN', level = 0)

plot(jpnDat, xlim = c(125, 145), ylim = c(30, 45), axes = T)
plot(korDat, xlim = c(125, 145), ylim = c(30, 45), add = T)
plot(rusDat, xlim = c(125, 145), ylim = c(30, 45), add = T)
plot(chnDat, xlim = c(125, 145), ylim = c(30, 45), add = T)
plot(prkDat, xlim = c(125, 145), ylim = c(30, 45), add = T)
scalebar(200, type = "bar", below = "km")

スクリーンショット 2021-03-09 15.17.09.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?