Mapping postal codes on country map using R


#1

I have csv with zip codes and business category. I want to map all categories on the country map using varying colors. How do I go about this using R? Please note: I do not have lat. and long. co-ordinates for the zip codes. Also, I am in non-US country (so can’t use zipcode package) Would appreciated any help from you guys.

Thanks in advance


#2

@sadashivb,

You can use library ggmap for returning latitude and longitude using zip code.

library(ggmap)
geocode(“110044”)

Output
lon lat
77.3333 28.5167

Regards,
Imran


#3

Hi @sadashivb,

After adding the lat & lon as suggested by @Imran you can do:

library(rworldmap)
newmap <- getMap(resolution = "low")
plot(newmap, xlim = c(-20, 59), ylim = c(35, 71), asp = 1)
points(airports$lon, airports$lat, col = "red", cex = .6)  

This should give something like:

Hope this helps!!


#4

Many thanks @imran & @shuvayan. Your suggestions worked fine. The only change I did from what suggested above was: in case of using pincode in geocode function, I used the place.