[R-sig-Geo] How to overlay world map using non-standard projection
Paul Hiemstra
p.hiemstra at geo.uu.nl
Thu Jan 20 12:09:40 CET 2011
Hi Elena,
Look at the spplot function and in particular to the sp.layout argument.
cheers,
Paul
On 01/19/2011 11:50 PM, ElenaC wrote:
> Dear all,
>
> I have a SpatialGrid (covering the entire world) in geographical coordinates
> that I'm trying to transform to equal-area cylindrical projection (such as
> given by CRS("+proj=cea +lat ts=30")). I also want to center the plot in the
> Pacific and overlay a map of the coasts on top.
>
> I have successfully transformed my SpatialGrid using the functions
> "projectExtent()" and "projectRaster()" from the raster package, and I've
> also centered the data where I want.
>
> Problem is that I've been unable to overlay a map of the world. I've tried
> to use the map() function, and I've generated the map I want (right
> projection and centered correctly) with the call:
>
> library(maps)
> world<-map(projection = "cylequalarea", parameter=30, interior=FALSE,
> wrap=TRUE, ylim=c(-60,60),xlim=c(-180,180), orientation=c(90,-205,0))
>
> But when I try to overlay this map on the plot of my transformed SpatialGrid
> I find that the scale of both maps is completely different. Their
> coordinates don't match:
>
>
>> bbox(mydata)
>>
> min max
> s1 -17352991 17352991
> s2 -6291291 6356742
>
>
>> range(world$x, na.rm=TRUE)
>>
> [1] -2.355834 2.355591
>
>> range(world$y, na.rm=TRUE)
>>
> [1] -0.8613535 0.8899210
>
> Moreover, it looks like it is a different scale factor affecting the 'x'
> and 'y' axis. Since the projection I'm trying to use dictates the ratio
> between the x and y axis, I don't understand how this can be.
>
> Any suggestion on how to proceed would be greatly appreciated..
>
> Thanks,
> Elena
>
>
--
Paul Hiemstra, MSc
Department of Physical Geography
Faculty of Geosciences
University of Utrecht
Heidelberglaan 2
P.O. Box 80.115
3508 TC Utrecht
Phone: +3130 253 5773
http://intamap.geo.uu.nl/~paul
http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770
currently @ KNMI
paul.hiemstra_AT_knmi.nl
More information about the R-sig-Geo
mailing list