[R-sig-Geo] Adding some data as colors to world map

Gregor Gorjanc gregor.gorjanc at gmail.com
Wed Mar 15 22:18:58 CET 2006


Hi!

Roger, many thanks for all this. I installed package sp and successfully
loaded object you provided and ploted the image you attached last time.
This is really nice. Thanks also for other comments for R and projections.

Btw. will you remove that world_countries.rda object or will it be
accessible in an R package or ???

Good luck!

Roger Bivand wrote:
> 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?
>>
>>Yes, please do.
> 
> 
> On:
> 
> http://spatial.nhh.no/R/etc/world_countries.rda
> 
> now, please let me know if it works for you. Please use library(sp) to 
> define the loaded object.
> 
> 
>>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
> 
> 
> 


-- 
Lep pozdrav / With regards,
    Gregor Gorjanc

----------------------------------------------------------------------
University of Ljubljana     PhD student
Biotechnical Faculty
Zootechnical Department     URI: http://www.bfro.uni-lj.si/MR/ggorjan
Groblje 3                   mail: gregor.gorjanc <at> bfro.uni-lj.si

SI-1230 Domzale             tel: +386 (0)1 72 17 861
Slovenia, Europe            fax: +386 (0)1 72 17 888

----------------------------------------------------------------------
"One must learn by doing the thing; for though you think you know it,
 you have no certainty until you try." Sophocles ~ 450 B.C.




More information about the R-sig-Geo mailing list