Create N-S and E-W grid lines over a geographic region
Create N-S and E-W grid lines over a geographic region
Create N-S and E-W grid lines over a geographic region; create and plot corresponding labels
gridlines(x, easts = pretty(bbox(x)[1,]), norths = pretty(bbox(x)[2,]), ndiscr =100)gridat(x, easts = pretty(bbox(x)[1,]), norths = pretty(bbox(x)[2,]), offset =0.5, side ="WS")## S3 method for class 'SpatialLines'labels(object, labelCRS, side =1:2,...)## S3 method for class 'SpatialPointsDataFrame'text(x,...)
Arguments
x: object deriving from class Spatial-class
easts: numeric; east-west values for vertical lines
norths: numeric; north-south values for horizontal lines
ndiscr: integer; number of points used to discretize the line, could be set to 2, unless the grid is (re)projected
offset: offset value to be returned, see text
object: SpatialLines-class object, as returned by gridlines
labelCRS: the CRS in which the grid lines were drawn and labels should be printed; if missing, the CRS from object is taken
side: for labels: integer, indicating side(s) at which gridlines labels will be drawn: 1=below (S), 2=left (W), 3=above (N), and 4=right (E); for gridat: default WS , if EN labels placed on the top and right borders
...: for labels: ignored; for text: arguments passed on to text , see below for example use of adj
Returns
gridlines returns an object of class SpatialLines-class , with lines as specified; the return object inherits the projection information of x; gridat
returns a SpatialPointsDataFrame with points at the west and south ends of the grid lines created by gridlines, with degree labels.
The labels method for SpatialLines objects returns a SpatialPointsDataFrame-class object with the parameters needed to print labels below and left of the gridlines. The locations for the labels are those of proj4string(object) the labels also unless labelCRS is given, in which case they are in that CRS. This object is prepared to be plotted with text:
The text method for SpatialPointsDataFrame puts text labels on its coordinates, and takes care of attributes pos, labels, srt and offset; see text .