[R] Statistical data and Map-package

Greg Snow Greg.Snow at intermountainmail.org
Tue Sep 26 17:02:10 CEST 2006


You may also want to look at the maptools (and sp) package, it can read
in and plot shapefiles from external sources.

Some sources of maps that maptools can plot include:

http://www.vdstech.com/map_data.htm
http://openmap.bbn.com/data/shape/timezone/ 
http://arcdata.esri.com/data_downloader/DataDownloader?part=10200&stack=
back

Hope this helps,


-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at intermountainmail.org
(801) 408-8111
 

-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Rense Nieuwenhuis
Sent: Tuesday, September 26, 2006 2:21 AM
To: r-help at stat.math.ethz.ch
Subject: [R] Statistical data and Map-package

Dear helpeRs,

I'm working with the map-package and came upon a problem which I
couldn't solve. I hope onee of you can. If not, this can be seen as a
suggestion for new versions of the package.

I'm trying to create a map of some European countries, filled with
colors corresponding to some values. Let's say I have the following
countries and I assign the following colors (fictional):

country2001 <- c("Austria", "Belgium", "Switzerland", "Czechoslovakia",
"Germany", "Denmark", "Spain", "Finland", "France", "UK", "Greece",
"Hungary", "Ireland", "Israel", "Italy", "Luxembourg", "Netherlands",
"Norway", "Poland", "Portugal", "Sweden", "Slovenia")
color2001 <- c("green", "yellow","red","red", "red", "red", "red",
"red", "green", "red", "red", "red", "red", "red", "red", "red", "red",
"blue", "red", "red", "red", "orange")

I then let the colors and the values correspond using 'match.map', like
this:

match <- match.map("world",country2001)
color <- color2001[match]

And finally I plot the map. It works perfectly fine.

map(database="world", fill=TRUE, col=color)


But as I mentioned, I want to create a map of Europe. So, I use xlim and
ylim to let some parts of the world fall of the map. The syntax becomes
like this:

map(database="world", fill=TRUE, col=color, xlim=c(-25,70),ylim=c
(35,71))

Now, a problem arises. The regions on the map are colored by the vector
'color'. It needs therefore to correspond to the order in which the
polygons are drawn. Since some of the full world-map isn't drawn this
time, the color-vector doesn't correspond anymore. This results in the
coloring of the wrong countries.

Does anybody know of a way to solve this?

Thanks very much in advance,

Rense Nieuwenhuis
	[[alternative HTML version deleted]]

______________________________________________
R-help at stat.math.ethz.ch 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.



More information about the R-help mailing list