如何用r中的区映射印度州? [英] How to map an Indian state with districts in r?

查看:25
本文介绍了如何用r中的区映射印度州?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 R 软件中用各自的地区绘制印度的不同州.我尝试使用2级GADM数据来获取坐标.

我已遵循此线程

 库(ggmap)qmap('Karnataka') 

I want to plot different states of India with respective districts in R software. I have tried using GADM, level 2 data to get the coordinates.

I have followed this thread Mapping just one State of India and writing its name inside the state boundary. However, I am unable to subset the data for any state and use it for mapping.

What I've tried:

map <- fortify(Karnataka)
map$id <- as.integer(map$id) 
dat <- data.frame(id = 216:242, district = Karnataka) 
map_df <- inner_join(map, dat, by = "id") 
centers <- data.frame(gCentroid(Karnataka, byid = TRUE)) 
centers$state <- dat$district

解决方案

You can do this beautifully and easily with Google Maps in R. Within ggmap there are a lot of options. The examples below are very basic but it's fully customizable by setting the options however you like them.

map <- qmap('Karnataka', zoom = 7, maptype = 'hybrid')
map

library(ggmap)
qmap('Karnataka')

这篇关于如何用r中的区映射印度州?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆