graticule: graticule: graticule lines for maps

Description Usage Arguments Details Examples

View source: R/graticule.R

Description

graticule: graticule lines for maps

Specify the creation of lines along meridians by specifying their placement at particular lons (longitudes) and lats (latitudes) and their extents with xlim (extent of parallel line in longitude) and ylim (extent of meridional line in latitude).

Usage

1
graticule(lons, lats, nverts = 60, xlim, ylim, proj = NULL, tiles = FALSE)

Arguments

lons

longitudes for meridional lines

lats

latitudes for parallel lines

nverts

number of discrete vertices for each segment

xlim

maximum range of parallel lines

ylim

maximum range of meridional lines

proj

optional proj.4 string for output object

tiles

if TRUE return polygons as output

Details

Provide a valid PROJ.4 string to return the graticule lines in this projection. If this is not specified the graticule lines are returned in their original longlat / WGS84.

The arguments xlim, ylim and nverts are ignored if tiles is TRUE.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
## Not run: 
library(rgdal)
x <- as.matrix(expand.grid(x = seq(100, 240, by = 15), y = seq(-85, -30, by = 15)))
prj <- "+proj=laea +lon_0=180 +lat_0=-70 +x_0=0 +y_0=0 +ellps=WGS84 +units=m +no_defs "
px <- project(x, prj)
g <- graticule(unique(x[,1]), unique(x[,2]))
pg <- spTransform(g, CRS(prj))
plot(px, type = "n")
plot(pg, add = TRUE)

g2 <- graticule(unique(x[,1]), unique(x[,2]), ylim = c(-90, 0), xlim = c(110, 250))
pg2 <- spTransform(g2, CRS(prj))
plot(px, type = "n")
plot(pg2, add = TRUE)

prj <- "+proj=laea +lon_0=0 +lat_0=-90 +ellps=WGS84"
xx <- c(-120, -100, -80, -60, -40); yy <- c(-65, -55, -45)
g3 <- graticule(xx, yy, ylim = c(-70, -30), proj = prj)
g3labs <- graticule_labels(xx, c(-65, -45), xline = -85, yline = -30, proj = prj)
plot(g3)
text(g3labs, lab = parse(text = g3labs$lab))

## polygonal graticule on Orthographic projection
xx <- seq(-90, 90, length = 10) + 147
yy <- seq(-90, 90, length = 5)
portho <- "+proj=ortho +lon_0=147 +x_0=0 +y_0=0 +ellps=WGS84 +units=m +no_defs"
 g <- graticule(xx, yy, proj = portho, tiles = TRUE)
 plot(g, col = c("black", "grey"))

 library(maptools)
 data(wrld_simpl)
 w <- spTransform(subset(wrld_simpl, NAME == "Australia"), CRS(projection(g)))
 plot(w, add = TRUE, border = "dodgerblue")
 
## End(Not run)

graticule documentation built on May 2, 2019, 9:43 a.m.