[R-sig-Geo] spplot not using exact xlim and ylim boundaries

Edzer Pebesma edzer.pebesma at uni-muenster.de
Mon Nov 28 21:52:09 CET 2011


It seems that your question has nothing to do with spplot (which is a
method in package sp), as you are using plot(). If the problem is
similar to this:

> plot(1:10,xlim=c(0,11),ylim=c(0,11))
> par()$usr
[1] -0.44 11.44 -0.44 11.44

then it doesn't have to do anything with plotting map data, and r-help
might be the more suitable list to ask. The following might help:

> plot(1:10,xlim=c(0,11),ylim=c(0,11),xaxs="i", yaxs="i")
> par()$usr
[1]  0 11  0 11

Best regards,

On 11/28/2011 09:20 PM, Jonathan Callahan wrote:
> I am plotting spatial data on transparent backgrounds for overlay on top of
> a GoogleMaps interface but they aren't *exactly* right.
> 
> I have set the size of GoogleMaps and my image to 640X640 and I receive
> bounds information on the current region from the GoogleMaps javascript API.
> 
> The problem is that the image generated by spplot does not strictly adhere
> to the xlim and ylim parameters I am passing in.
> 
> As an example, here is some debugging of a plot of watershed basins
> 
>   print(paste("map_west = ",w,", map_east =",e,", map_south = ",s,",
> map_north = ",n))
>   xlim = c(w,e)
>   ylim = c(s,n)
>   plot(basin,xlim=xlim,ylim=ylim,border=col_basin,lwd=lwd_basin)
>   print(paste("usr_west = ",format(par()$usr[1],digits=7,nsmall=4),",
> usr_east =",format(par()$usr[2],digits=7,nsmall=4),
>               ", usr_south = ",format(par()$usr[3],digits=6,nsmall=4),",
> usr_north = ",format(par()$usr[4],digits=6,nsmall=4)))
> 
> And here is the resulting text output:
> 
> [1] "map_west =  -124.4348 , map_east = -123.6252 , map_south =  43.8856 ,
> map_north =  44.4652"
> [1] "usr_west =  -124.4672 , usr_east = -123.5928 , usr_south =  43.8618 ,
> usr_north =  44.4890"
> 
> 
> Things are close but not *exactly* right. Is there anything I can do to
> force spplot to stick to the boundaries I have passed in?
> 
> I am using R 2.13.1 and sp 0.9-85.
> 
> Thanks in advance.
> 

-- 
Edzer Pebesma
Institute for Geoinformatics (ifgi), University of Münster
Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251
8333081, Fax: +49 251 8339763  http://ifgi.uni-muenster.de
http://www.52north.org/geostatistics      e.pebesma at wwu.de



More information about the R-sig-Geo mailing list