Skip to content

Maps of continents

6 messages · Roman Luštrik, Gilles Benjamin Leduc, Rui Barradas +1 more

#
Hello,

This is a really basic question. I'm an R user but completely ignorant 
on geographical applications.
I need to graph the 5 Continents, one on each graph. How can I do it? 
Which packages do I need to have installed and use?.

Thank you,

Rui Barradas
#
Have you tried package "rworldmap"? It comes with a vignette

install.packages("rworldmap")
library(rworldmap)
vignette("rworldmap")

Another packages that contains world maps is
library(maps)
map()

Cheers,
Roman
On Wed, Apr 29, 2015 at 11:18 AM, Rui Barradas <ruipbarradas at sapo.pt> wrote:

            

  
    
#
Hi 

So, I would advise you: Find nice shapefiles of the world: 
http://www.diva-gis.org/datadown 
http://spatialanalysis.co.uk/  

Then you load it, either :
 library(maptools)
bordures<-readShapeSpatial("10m_cultural/ne_10m_admin_0_countries.shp") 

Or better:
library(rgdal)
readOGR(dsn="10m_cultural", layer="ne_10m_admin_0_countries")->bordures

then plot with good limits (here France)
plot(bordures,xlim=c(?-4.3,9.1),ylim=c(41,51),axes = TRUE, col="grey") 

I hope it helps

Benjamin
On Wednesday, April 29, 2015 09:18 GMT, Rui Barradas <ruipbarradas at sapo.pt> wrote:

            
#
Hello,

Thank you. Now I have another problem, when I run the code you've 
provided error messages occur.

 > library(maptools)
 > bordures<-readShapeSpatial("10m_cultural/ne_10m_admin_0_countries.shp")
Error in getinfo.shape(fn) : Error opening SHP file
 >
 > library(rgdal)
 > readOGR(dsn="10m_cultural", layer="ne_10m_admin_0_countries")->bordures
Error in ogrInfo(dsn = dsn, layer = layer, encoding = encoding, 
use_iconv = use_iconv,  :
   Cannot open file


How can I solve this?

Rui Barradas


 > sessionInfo()
R version 3.2.0 (2015-04-16)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=Portuguese_Portugal.1252 
LC_CTYPE=Portuguese_Portugal.1252
[3] LC_MONETARY=Portuguese_Portugal.1252 LC_NUMERIC=C 

[5] LC_TIME=Portuguese_Portugal.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] maps_2.3-9      rworldmap_1.3-1 rgdal_0.9-2     maptools_0.8-36
[5] sp_1.1-0

loaded via a namespace (and not attached):
[1] tools_3.2.0     foreign_0.8-63  fields_8.2-1    grid_3.2.0
[5] spam_1.0-1      lattice_0.20-31



Em 29-04-2015 12:23, Gilles Benjamin Leduc escreveu:
#
Hello,

Thanks, I will look into the vignette.

Rui Barradas

Em 29-04-2015 10:34, Roman Lu?trik escreveu:
#
Dear Rui Barradas,

I'm sure you can get this work and get excellent results. However, I think the *easiest* solution is to get rworldmap package (like suggested earlier in this thread), where you do not need to do so many tricks to do what you try to do. For instance, plotting continents is much easier with rworldmap if you want to define the continent by geographical areas instead of a longitude/latitude ranges containing the continent plus other areas in that range.

Cheers, Jari Oksanen
On 29/04/2015, at 17:34 PM, Rui Barradas wrote: