1

R でインドの地図を生成したいと考えています。州ごとに異なる値を持つ 5 つの指標があります。5 つの異なる色でバブルをプロットしたいのですが、そのサイズはすべての状態での強度を表す必要があります。例えば:

State A B C D E
Kerala - 39, 5, 34, 29, 11
Bihar - 6, 54, 13, 63, 81
Assam - 55, 498, 89, 15, 48,
Chandigarh - 66, 11, 44, 33, 71

私の問題に関連するいくつかのリンクを調べました:

[1] http://www.r-bloggers.com/nrega-and-indian-maps-in-r/

[2]インド向けの R パッケージ?

しかし、これらのリンクは私の目的を果たすことができませんでした。この方向での助けをいただければ幸いです。

私も試してみました

library(mapproj)
map(database= "world", regions  = "India", exact=T, col="grey80", fill=TRUE, projection="gilbert", orientation= c(90,0,90))

lat <- c(23.30, 28.38)

lon <- c(80, 77.12) # Lon and Lat for two cities Bhopal and Delhi

coord <- mapproject(lon, lat, proj="gilbert", orientation=c(90, 0, 90))

points(coord, pch=20, cex=1.2, col="red")

一言で言えば、問題は次のとおりです。 (1) 地区レベルでプロットが表示されません。州の境界でさえありません。(2)プロットする場所の名前と対応する値しかない場合、このプロットでデータのバブルまたはドットを作成する方法は? (3)これはまたはで簡単に実行できますlibrary(RgoogleMaps)library(ggplot2)?(推測ですが、これらのパッケージについてはあまり知りません)

4

2 に答える 2

3

@lawyeR が述べているように、コロプレス (または主題) マップは、マップ上の変数を表すためにより一般的に使用されます。これには、変数ごとに 1 つのマップを作成する必要があります。例を見てみましょう:

require("rgdal")  # needed to load shapefiles

# obtain India administrative shapefiles and unzip
download.file("http://biogeo.ucdavis.edu/data/diva/adm/IND_adm.zip", 
              destfile = "IND_adm.zip")
unzip("IND_adm.zip", overwrite = TRUE)

# load shapefiles
india <- readOGR(dsn = "shapes/", "IND_adm1")

# check they've loaded correctly with a plot
plot(india)

# all fine. Let's plot an example variable using ggplot2
require("ggplot2")
require("rgeos")  # for fortify() with SpatialPolygonsDataFrame types

india@data$test <- sample(65000:200000000, size = nrow(india@data),
                          replace = TRUE)

# breaks the shapefile down to points for compatibility with ggplot2
indiaF <- fortify(india, region = "ID_1")
indiaF <- merge(indiaF, india, by.x = "id", by.y = "ID_1")

# plots the polygon and fills them with the value of 'test'
ggplot() +
  geom_polygon(data = indiaF, aes(x = long, y = lat, group = group,
                                  fill = test)) +
  coord_equal()

最後に、あなたが GIS SE で同じ質問をしたことに気付きました。これは悪い習慣と見なされ、一般的に眉をひそめているため、その質問はこれの複製としてクローズするようにフラグを立てました. 一般的な経験則として、重複を作成しないようにしてください。

幸運を!

于 2015-04-27T12:12:00.457 に答える
1

インドのシェープファイルを取得したら、コロプレスを作成する必要があります。これはシェープフル マップを取得し、データを反映するグラデーションでインドの各州に色を付けます。5 つのプロットのパネルを作成し、それぞれがインドとその州を 5 つの変数の 1 つに従って色分けして表示することができます。

この回答をさらに進めることができる他の人のためdputに、少しクリーニングした後のデータフレームを次に示します。

dput(df)
structure(list(State = c("Kerala", "Bihar", "Assam", "Chandigarh"
), A = c("39", "6", "55", "66"), B = c("5", "54", "498", "11"
), C = c("34", "13", "89", "44"), D = c("29", "63", "15", "33"
), E = c("11", "81", "48", "71")), .Names = c("State", "A", "B", 
"C", "D", "E"), row.names = c("Kerala", "Bihar", "Assam", "Chandigarh"
), class = "data.frame") 
于 2015-04-26T14:15:02.907 に答える