Skip to content

Help with maps

4 messages · Avram Aelony, Ray Brownrigg

#
On Tuesday, December 02, 2008, at 04:40PM, "hadley wickham" <h.wickham at gmail.com> wrote:
Thanks for this.
What format is best?  I don't really have an example, because I only have a data frame with geo and count data.

The map() function gives me the following
head> head(d)
          x        y
1 -86.81457 32.34920  #presumably latitudes and longitudes ???
2 -86.81457 32.33774
3 -86.80311 32.32628
4 -86.79737 32.32055
5 -86.78019 32.32628
6 -86.78019 32.34347

and I am not sure how to join this with data from a csv formatted file with columns for country, state, county, zip code, a, b, c, where a,b,c are integers.   Ideally, I'd like to show a map of the US by county that represents the sum of all "a" in that county with darker colors for larger values of x ...  Then I'd like to do the same for the UK.  If I could do the same at the zip code level for certain counties, that would be even better.
Doesn't that assume that county names and associated counts are mapped to lat/lon ?  How does the map() function understand "france" or "county" so that it can do this internally?  I'd like map() to figure out the lat/lon details.


head> head(d)   
          x        y
1 -86.81457 32.34920
2 -86.81457 32.33774
3 -86.80311 32.32628


Doesn't each row correspond to a vertex?  How to get from vertices to county names with associated counts?
This produces a very small UK in the upper left quadrant.
thanks again in advance
#
On Wed, 03 Dec 2008, Avram Aelony wrote:
Don't restrict your output to only x and y then.  Have a look at:
map("county", plot=FALSE)$names

Here each row corresponds to the polygon (county) represented by the corresponding set of 
x and y values in d (up to the next NA).
Again:
map('world', regions="uk")$names
shows you all the islands that are also associated with the UK.

The easiest way would be:
map('world', regions="UK", xlim=c(-10, 5), ylim=c(48, 60))

then use map.axes() to refine this.

HTH
Ray Brownrigg
MSCS, Victoria University of Wellington
#
On Wed, 03 Dec 2008, Ray Brownrigg wrote:

            
But of course:

map('world', regions=c("UK", "Ireland"), xlim=c(-10, 5), ylim=c(48, 60))

might be more appropriate.

HTH
Ray Brownrigg
MSCS, Victoria University of Wellington
1 day later
#
aha!, thanks for this.
Avram
On Dec 2, 2008, at 5:38 PM, Ray Brownrigg wrote: