[R] Creating a map with central Asian countries

Gesmann, Markus Markus.Gesmann at lloyds.com
Thu Sep 15 11:26:01 CEST 2011


Salaam,

If you would like to display the chart online than the googleVis package might be helpful.
The package provides you with an interface to the Google Visualisation API.
Here is an example with a map of the population on the central Asian countries:

library(googleVis)
## googleVis comes with the data set Population

myData <- subset(Population, Country %in% c("Uzbekistan", "Kazakhstan", "Tajikistan", "Kyrgyzstan", "Turkmenistan"))

## create a geo chart, using the Google Visualisation API, 
## an internet connection is required to display the chart

plot(gvisGeoChart(myData, locationvar='Country', numvar='Population', options=list(region='143')))
 
I hope this helps.

Regards

Markus

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Barry Rowlingson
Sent: 15 September 2011 09:58
To: Salaam Batur
Cc: r-help at r-project.org
Subject: Re: [R] Creating a map with central Asian countries

On Thu, Sep 15, 2011 at 8:41 AM, Salaam Batur <swordlight20 at gmail.com> wrote:
> Dear all,
>
> I am trying to create a map for central asian countries(Kazakhstan, 
> Uzbekstan, Kyrgyzstan, Turkmenstan, and Tajikstan). I tried google for 
> shapefiles and Rdata files of central asia, but I can't seem to find them.
> There is only a world map and individual maps for each countries. If I 
> use individual maps to create this map, how do I put them on a same 
> graphic with different colours? Any ideas?

 If you are reading the country shapefiles (I get mine from
www.gadm.org) into SpatialPolygonsDataFrames with the readShapeSpatial function from package:maptools then you could either 'rbind' the five countries into one SpatialPolygonsDataFrame or do an empty plot with the lat-long bounds and then plot them with 'add=TRUE'. Something like (I've not tested this)

tajikistan = readShapeSpatial("TJK_adm0.shp")
plot(0,xlim=c(64,78),ylim=c(35,42))   # maybe other options for axis
and labels here
plot(tajikistan,add=TRUE)

 Any problems with maps, shapefiles etc are probably best asked on r-sig-geo mailing list, or www.stackoverflow.com with an R tag...

Barry

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
**********************************************************************
The information in this E-Mail and in any attachments is...{{dropped:27}}



More information about the R-help mailing list