Skip to content

Help with maps

3 messages · Avram Aelony, Hadley Wickham, zerfetzen

#
A few questions about maps...

(1) How can I find a listing of the internal data sets that map() from the maps library contains?
For example, "usa", "county", "state", "nz" all work.  Are there any others?

(2) Is there an easier, more generalized way to produce this (http://www.ai.rug.nl/~hedderik/R/US2004/ ) type of plot than this (http://www.ai.rug.nl/~hedderik/R/US2004/map.r ) ?  I have geographic (e.g. country, state, county, zip code) count data in a data frame that I would like to represent on a map, but still need to study how map.r works, especially the map.center function...

(3) The examples at http://had.co.nz/ggplot2/coord_map.html are great.  Adding another example that with color codes for counts from a data frame would be very useful too.

(4) Is there a reason why I can produce a map of France but not the UK ?
Error in get(dbname) : variable "ukMapEnv" was not found
In addition: Warning message:
In data(list = dbname) : data set 'ukMapEnv' not found

( version 2.8.0, on win xp currently)

Thanks in advance,
Avram
#
On Tue, Dec 2, 2008 at 6:21 PM, Avram Aelony <aavram at mac.com> wrote:
help(package = maps)
Yes, it's about six lines of ggplot2 code.  But a lot depends on the
format of your data, so if you could provide a reproducible example of
what you're trying to do, that would be very helpful.
qplot(..., colour = count) ?
map('world', regions="uk")

Hadley
3 days later
#
I'm brand new to the map function too, here's my attempt at coloring a map of
the states according to a rate (rather than count):

map('state')$names
MyCount <- c(1:63); MyRate <- runif(63, 0, 1)
map('state', fill=TRUE, col=rgb((1-MyRate),MyRate,0,1))

Seeing that there are 63 "states", means you'll have to adjust your data to
fit.  For example, look at Washington.  I think the effect of MyRate on
color is that as it approaches 1, rgb produces green, and as it approaches
0, rgb produces red.  I know you were asking for counts, but I just had this
handy, and I'm learning too.  Cheers.