[R-sig-Geo] map projection problem
Melanie Abecassis
Melanie.Abecassis at noaa.gov
Wed Apr 2 04:21:49 CEST 2008
Hi,
I am unsuccessfully trying to change the map projection in map function
of the maps library.
Here is my code :
library(maps)
library(mapdata)
library(mapproj)
map(database = "world", fill = TRUE, col = 1, plot = TRUE,add=F,
xlim = c(-200,-120), ylim = c(-5,45))
map.axes()
This gives me a map centered on Hawaii.
I now want to have *the same map but in the mercator projection* :
map(database = "world", fill = TRUE, col = 1, plot = TRUE,add=F,
projection="mercator", xlim = c(-200,-120), ylim = c(-5,45))
map.axes()
And I get a weird map of the US and parts of Canada only.
Then I tried this :
A=mapproject(c(-200,-120), c(-5,45), projection="mercator")
map(database = "world", fill = TRUE, col = 1, plot = TRUE,add=F,
projection="mercator", xlim = A$x, ylim = A$y)
map.axes()
which should be the correct way to do this I think, but I get this :
Error in map.poly(database, regions, exact, xlim, ylim, boundary,
interior, :
nothing to draw: all regions out of bounds
Could anyone help me with this ?
Thanks a lot,
Melanie
More information about the R-sig-Geo
mailing list