plot - Map of India in R with Different Values of Five Indicators for Every State of India -
i want generate map of india in r. have 5 indicators different values of every state. want plot bubbles 5 different colors, , size should represent intensity in every state. example:
state 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
i have gone through links related problem:
[1] http://www.r-bloggers.com/nrega-and-indian-maps-in-r/
but these links not serve purpose. in direction appreciated.
i have tried
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 , lat 2 cities bhopal , delhi coord <- mapproject(lon, lat, proj="gilbert", orientation=c(90, 0, 90)) points(coord, pch=20, cex=1.2, col="red")
in nut shell problems are: (1) not give me plot @ district level. not boundries of states. (2) how create bubbles or dots of data in plot, if have name of locations , corresponding value plot? (3) can done in in library(rgooglemaps)
or library(ggplot2)
? (just guess, not know these packages)
as @lawyer states, choropleth (or thematic) map more commonly used represent variables on map. require produce 1 map per variable. let me take through example:
require("rgdal") # needed load shapefiles # obtain india administrative shapefiles , 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 plot plot(india) # fine. let's plot example variable using ggplot2 require("ggplot2") require("rgeos") # fortify() spatialpolygonsdataframe types india@data$test <- sample(65000:200000000, size = nrow(india@data), replace = true) # breaks shapefile down points compatibility ggplot2 indiaf <- fortify(india, region = "id_1") indiaf <- merge(indiaf, india, by.x = "id", by.y = "id_1") # plots polygon , fills them value of 'test' ggplot() + geom_polygon(data = indiaf, aes(x = long, y = lat, group = group, fill = test)) + coord_equal()
finally, notice asked same question on gis se. considered bad practice , frowned upon, i've flagged question closed duplicate of this. general rule of thumb try not create duplicates.
good luck!
Comments
Post a Comment