Rで解析:地球儀にデータを表示「globe」パッケージ

Rの解析に役に立つ記事
スポンサーリンク

地図をプロットするパッケージは数多くありますが、地球規模のデータ表示に役に立つパッケージの紹介です。コマンド例では2022/9/22に発生した台風NORUの台風経路も合わせて紹介します。使いやすいパッケージです。

パッケージバージョンは1.2-0。windows11のR version 4.2.2で確認しています。

スポンサーリンク

パッケージのインストール

下記、コマンドを実行してください。

#パッケージのインストール
install.packages("globe")

実行コマンド

詳細はコメント、パッケージのヘルプを確認してください。

#パッケージの読み込み
library("globe")

#配列を緯度・軽度のリスト式に変換:ensurelonlatコマンド
#札幌駅の位置を指定
LonLatData <- ensurelonlat(c(141.21, 43.3))

#&#25351;&#23450;&#20301;&#32622;&#12434;&#20013;&#24515;&#12395;&#12375;&#12383;&#22320;&#29699;&#20736;&#12434;&#12503;&#12525;&#12483;&#12488;:globeearth&#12467;&#12510;&#12531;&#12489;
#&#34920;&#31034;&#20301;&#32622;&#12398;&#25351;&#23450;:eye&#12458;&#12503;&#12471;&#12519;&#12531;;list(lon,lat)&#12391;&#25351;&#23450;&#12377;&#12427;&#12363;,&#20197;&#19979;&#12424;&#12426;&#36984;&#25246;
#&lsquo;nedlands&rsquo;,&lsquo;curtin&rsquo;,&lsquo;perth&rsquo;,&lsquo;northpole&rsquo;,&lsquo;southpole&rsquo;,&lsquo;casey&rsquo;,&lsquo;mawson&rsquo;,
#&lsquo;madrid&rsquo;,&lsquo;aarhus&rsquo;,&lsquo;aalborg&rsquo;,&lsquo;newyorkcity&rsquo;,&lsquo;titanic&rsquo;,&lsquo;pyongyang&rsquo;,&lsquo;everest&rsquo;,&lsquo;kilimanjaro&rsquo;
#&#38914;&#28857;&#20301;&#32622;&#12434;&#25351;&#23450;:top&#12458;&#12503;&#12471;&#12519;&#12531;
globeearth(eye = LonLatData, top = place("northpole"))

#&#12503;&#12525;&#12483;&#12488;&#12375;&#12383;&#22320;&#29699;&#20736;&#12395;&#12471;&#12531;&#12508;&#12523;&#12434;&#36861;&#21152;:globepoints&#12467;&#12510;&#12531;&#12489;
#&#22580;&#25152;&#12434;&#25351;&#23450;:loc&#12458;&#12503;&#12471;&#12519;&#12531;;matrix&#12391;&#25351;&#23450;
#base&#12398;plot&#12434;&#21033;&#29992;&#12375;&#12390;&#12356;&#12427;&#12398;&#12391;plot&#12398;&#12458;&#12503;&#12471;&#12519;&#12531;&#20351;&#29992;&#12364;&#21487;&#33021;&#12391;&#12377;
#&#26032;&#21315;&#27507;&#31354;&#28207;&#12392;&#32701;&#30000;&#31354;&#28207;&#12434;&#25351;&#23450;
LocPoint <- t(matrix(c(141.40, 42.47, 139.46, 35.32), nrow = 2, ncol = 2))
globepoints(loc = LocPoint, eye = LonLatData, top = place("northpole"),
            col = "red", pch = 17)

#&#12503;&#12525;&#12483;&#12488;&#12375;&#12383;&#22320;&#29699;&#20736;&#12395;&#32076;&#32218;&#12434;&#36861;&#21152;:globedrawlat&#12467;&#12510;&#12531;&#12489;
globedrawlat(lat = seq(-90, 90, 15))

#&#12503;&#12525;&#12483;&#12488;&#12375;&#12383;&#22320;&#29699;&#20736;&#12395;&#32239;&#32218;&#12434;&#36861;&#21152;:globedrawlong&#12467;&#12510;&#12531;&#12489;
globedrawlong(lon = seq(-180,180,30))

#&#12503;&#12525;&#12483;&#12488;&#12375;&#12383;&#22320;&#29699;&#20736;&#12395;&#32218;&#12434;&#36861;&#21152;:globearrows&#12467;&#12510;&#12531;&#12489;
#&#32218;&#12398;&#38263;&#12373;:len&#12458;&#12503;&#12471;&#12519;&#12531;
globearrows(loc = LocPoint, eye = LonLatData, top = place("northpole"),
            col = "red", len = 3.5)

#&#19990;&#30028;&#22320;&#22259;&#12434;&#25551;&#20889;:flatearth&#12467;&#12510;&#12531;&#12489;
#&#22259;&#27861;&#12434;&#25351;&#23450;:projection&#12458;&#12503;&#12471;&#12519;&#12531;;atlas:&#12450;&#12488;&#12521;&#12531;&#12486;&#12451;&#12473;&#22259;&#27861;,cylindrical:&#20870;&#31570;&#22259;&#27861;
flatearth("atlas")

#&#12503;&#12525;&#12483;&#12488;&#12375;&#12383;&#19990;&#30028;&#22320;&#22259;&#12395;&#12471;&#12531;&#12508;&#12523;&#12434;&#36861;&#21152;:flatpoints&#12467;&#12510;&#12531;&#12489;
#&#12458;&#12503;&#12471;&#12519;&#12531;&#12399;globepoints&#12467;&#12510;&#12531;&#12489;&#12392;&#12411;&#12412;&#21516;&#12376;&#12391;&#12377;
flatpoints(loc = LocPoint, col = "red", pch = 17)

#&#21442;&#32771;:2022/9/22&#12395;&#30330;&#29983;&#12375;&#12383;&#21488;&#39080;NORU&#12398;&#21488;&#39080;&#32076;&#36335;
#&#27671;&#35937;&#24193;:https://www.data.jma.go.jp/yoho/typhoon/position_table/table2022.csv
TyphoonPoint <- t(matrix(c(133, 17.4, 133.7, 17.6, 134.2, 17.7,
                           134.4, 17.7, 134.4, 17.9, 134.1, 18,
                           133.5, 17.9, 132.4, 17.6, 131.3, 17.6,
                           130.6, 17.5, 129.2, 16.9, 128.1, 16.3,
                           126.9, 15.8, 126, 15.4, 124.7, 15.2,
                           123.6, 15, 122.5, 15, 121.4, 15.2,
                           119.7, 15.5, 118.4, 16.2, 116.9, 15.9,
                           115.5, 15.9, 113.5, 15.8, 112, 15.5,
                           111.2, 15.6, 109.9, 15.8, 108.8, 15.8,
                           107.9, 15.9, 107.3, 15.9, 105, 16,
                           104.9, 16, 103.9, 16, 103.3, 16),
                         nrow = 2))
globeearth(eye = LonLatData, top = place("northpole"))
globepoints(loc = TyphoonPoint, eye = LonLatData, top = place("northpole"),
            col = "#a87963", pch = 17)

出力例

・globeearthコマンドに点や緯線などを追加した例

globepoints

・flatearthコマンド

flatearth

・台風26の台風経路


少しでも、あなたの解析が楽になりますように!!

タイトルとURLをコピーしました