library(ggmap) # -- for geocoding, obtaining city locations
readRDS("gadm36_IND_2_sp.rds")
ind2 = gadm
The output at the end is as below:
Slot "bbox": min max x 68.186249 97.41516 y 6.754256 35.50133
Slot "proj4string": CRS arguments: +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 Error in eval(expr, envir, enclos): object 'gadm' not found Traceback:
After that the next code is :
# plotting districts of a State, in this case West Bengal
wb2 = (ind2[ind2$NAME_1=="West Bengal",])
nam = c("Purulia","Bankura","Midnapur")
pos = geocode(nam)
tlat = pos$lat+0.05 # -- the city name will be above the marker
cities = data.frame(nam, pos$lon,pos$lat,tlat)
names(cities)[2] = "lon"
names(cities)[3] = "lat"
text1 = list("panel.text", cities$lon, cities$tlat, cities$nam,col="red", cex = 0.75)
mark1 = list("panel.points", cities$lon, cities$lat, col="blue")
text2 = list("panel.text",87.0,26.0,"GADM map", col = "dark green", cex = 1.2)
spplot(wb2, "NAME_1",
sp.layout=list(text1,mark1, text2),
main="West Bengal Districts",
colorkey=FALSE, scales=list(draw=TRUE))
The output for the above code is: Error in eval(expr, envir, enclos): object 'ind2' not found Traceback:
How to plot locations in map?