[R] Plot SpatialLinesDataFrame with xlim ylim

2007-07-11 Thread Edzer J. Pebesma
Michael,

The plot method for SpatialLinesDataFrame objects resides in package sp, 
and questions regarding it are easier noticed on the r-sig-geo mailing 
list.

The reason why they are plotted with aspect ratio 1 is that they are 
assumed to be spatial (geographical) data, and assume that 1 m north 
equals 1 m west -- think of a map. The exception is when the projection 
argument is set to longlat data (i.e. decimal degrees North/East), where 
the aspect ratio is computed differently, such that the argument above 
more or less holds.

You should be able to override the default aspect setting by explicitly 
passing the e.g. asp=0.5 argument to plot.

Here's the comment in the documentation of plot for Spatial objects 
(such as SpatialLinesDataFrame):

The default aspect for map plots is 1; if however data are not projected 
(coordinates are longlat), the aspect is by default set to 1/cos(My * 
pi)/180) with My the y coordinate of the middle of the map (the mean of 
ylim, which defaults to the y range of bounding box).

The argument |setParUsrBB| may be used to pass the logical value |TRUE| 
to functions within |plot.Spatial|. When set to |TRUE|, par(“usr”) will 
be overwritten with |c(xlim, ylim)|, which defaults to the bounding box 
of the spatial object. This is only needed in the particular context of 
graphic output to a specified device with given width and height, to be 
matched to the spatial object, when using par(“xaxs”) and par(“yaxs”) in 
addition to |par(mar=c(0,0,0,0))|.
--

Edzer

I'm running windows xp, R 2.3.1 with maptools 0.6-6, I guess. 
When plotting from a large SpatialLinesDataFrame and using xlim  ylim to 
reduce the area, the plot axes automatically have the same scale size, even if 
xlim and ylim ranges differ.  
E.g.:
tmp - readShapeLines(filepath)
plot(tmp,xlim=c(-126,-119),ylim=c(50,51))

The y-axis range is actually 47-54, same range as the x-axis.  What am I doing 
wrong?  Should I be using a different object for simple coastline  river data?
Thanks in advance!
Michael

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Plot SpatialLinesDataFrame with xlim ylim

2007-07-10 Thread Folkes, Michael
I'm running windows xp, R 2.3.1 with maptools 0.6-6, I guess. 
When plotting from a large SpatialLinesDataFrame and using xlim  ylim to 
reduce the area, the plot axes automatically have the same scale size, even if 
xlim and ylim ranges differ.  
E.g.:
tmp - readShapeLines(filepath)
plot(tmp,xlim=c(-126,-119),ylim=c(50,51))

The y-axis range is actually 47-54, same range as the x-axis.  What am I doing 
wrong?  Should I be using a different object for simple coastline  river data?
Thanks in advance!
Michael

___
Michael Folkes
Salmon Stock Assessment
Canadian Dept. of Fisheries  Oceans 
Pacific Biological Station
3190 Hammond Bay Rd.
Nanaimo, B.C., Canada
V9T-6N7
Ph (250) 756-7264 Fax (250) 756-7053  [EMAIL PROTECTED]


[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.