On Sat, 11 Mar 2006, Gregor Gorjanc wrote:
Hello!
I appologize for my absence but I was completely stuffed with my work in
last days. I would like to express thanks to all who took their time and
showed various ways how to accomplish my task. I did not expect to get
so many valuable responses. I will plot data from FAOSTAT database
http://faostat.fao.org/faostat/collections?subset=agriculture
Using world_countries.rda (see below for access) and matching against a
short sample csv from FAO (they don't seem to give access to more than 25
line samples without registration) - sample for Oceania:
world_countries$ISO3166[match(toupper(as.character(oc_aa$Country)),
as.character(world_countries$names))]
[1] AS AU CK <NA> PF GU KI MH <NA> NC NZ NU NF <NA> PW
[16] PG WS SB TO TV VU <NA>
230 Levels: AD AE AF AG AI AL AM AN AO AR AS AT AU AW AZ BA BB BD BE BF ... ZW
looks promising - you'll still have a bit of manual editing to add the
ISO3166 codes to the FAO data. But it can be done once-off, I guess, as
you said.
I've produced a world map with ISO3166 two-letter codes. To get your
codes right - this lists out country names and codes:
as(world_countries, "data.frame")
OK, I will need to do the mapping, since FAO uses full names for
countries, but that is a minor problem. I will just create a list of
mappings and apply it.
then
countries <- c("AU", "US", "AR") colours <- c("blue", "red", "green")
plot(world_countries, col=colours[match(world_countries$ISO3166,
countries)])
The classInt package new on CRAN can help, if you like, with choosing
colours for the polygons or bubbles.
Very clean and nice solution. I like it. If I would also go for bubbles,
how can I determine the position where to put the bubble on i.e. "the
center" of the country?
symbols(coordinates(world_countries), ...)
should do it. Have a look at Susumu Tanimura et al. in JSS 2006 for a nice
discussion of symbol size.
gives the attached PNG. Shall I make an .RData file of the
SpatialPolygonsDataFrame object available?
Many thanks again!!!
P.S. In one of previous posts you mentioned
The advantage of the sp class representation here is that we can
project the data to make areas more comparable if you need that,
otherwise Greenland, Russia, and Canada dominate totally!
Can you please elaborate a bit further on this topic since I do not
follow it fully. Perhaps you can show on above example.
The specific choice of the projection depends on which part of the world
you want to present, and on other cartographic criteria. This is a good
reference:
http://www.colorado.edu/geography/gcraft/notes/mapproj/mapproj_f.html
but there are thousands of interesting choices, I'm afraid. Projection is
supported in the newest version of rgdal on CRAN using the transform()
method, but you need to know which coordinate reference system to go to.
If there is a typical projection used in your field, it should be
identifiable, and can then be done to make a projected basemap.
P.P.S. Did you "get any further" with Giovanni's tutorial and recent
changes in maptools?
Not yet, but it'll come before too long!
Best wishes,
Roger