印度的R套餐?

Gee*_*ata 5 r ggplot2

我在美国的R区进行了大量的统计分析.但我也想为印度做一些研究.我找到了州地图,但没有地区地图.我可以在d3.js中找到这样的东西,但我宁愿不放弃R.

印度是否有类似"地图"的R套餐.

Hor*_*ear 8

您可以使用来自GADM的数据,其中包含不同级别的行政区划中的shapefile,因此我认为也是2级的区级别.您可以使用下面的脚本直接加载数据,代码从这里获取.

所以在你的情况下你会运行:

IND<-getCountries("IND",level=2)
Run Code Online (Sandbox Code Playgroud)

只是为了检查,绘制数据:

plot(ind)
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

或者,您可以使用GAUL数据并使用加载shapefile maptools.

获取数据的代码.

# Load required libraries
library(sp)

# Load file from GADM
# Specify the countries for fileName using ISO3C
# like "AFG" for Afghanistan.
# "level" specifies adminsitrative level.
loadGADM<-function(fileName,level=0,...){
load(url(paste("http://gadm.org/data/rda/",fileName,"_adm",level,".RData",sep = "")))
gadm
}

# Add prefix (ISO3C code) to shapefile.
changeGADMPrefix<-function(GADM, prefix) {
GADM <- spChFIDs(GADM, paste(prefix, row.names(GADM), sep = "_"))
GADM
}

# Load file and change prefix
loadChangePrefix<-function (fileName, level = 0, ...) {
theFile <- loadGADM(fileName, level)
theFile <- changeGADMPrefix(theFile, fileName)
theFile
}

# Apply all the functions:
getCountries <- function (fileNames, level = 0, ...) {
polygon <- sapply(fileNames, loadChangePrefix, level)
polyMap <- do.call("rbind", polygon)
polyMap
}
Run Code Online (Sandbox Code Playgroud)

  • 这是个好问题.因此,如果我将情节与官方地图进行比较,似乎对于Jamnu&Kashmir来说,中国和巴基斯坦控制线下的区域都不见了.正确?包含它们的一种方法是加载CHN和PAK的ADM2级别数据,然后将数据子集化,以包括所有印度地区以及克什米尔的中国和巴基斯坦地区.所以那些将是中国的Aksai Chin,以及巴基斯坦的Azad-Kasmir和Gilgit-Balistan. (2认同)