From 0338cdbac3b166d828740b58f519b249454f925c Mon Sep 17 00:00:00 2001 From: Edzer Pebesma Date: Wed, 3 Feb 2016 23:16:13 +0100 Subject: [PATCH] change default ndiscr; tidy docs & demo --- R/gridlines.R | 2 +- demo/polar.R | 9 ++++----- man/gridlines.Rd | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/R/gridlines.R b/R/gridlines.R index ce79bf2..0f7712d 100644 --- a/R/gridlines.R +++ b/R/gridlines.R @@ -15,7 +15,7 @@ degreeLabelsEW = function(x) { } gridlines = function(x, easts = pretty(bbox(x)[1,]), - norths = pretty(bbox(x)[2,]), ndiscr = 20) + norths = pretty(bbox(x)[2,]), ndiscr = 100) { if (missing(x)) { easts = seq(-180,180,20) diff --git a/demo/polar.R b/demo/polar.R index 32f1bc2..9d14db4 100644 --- a/demo/polar.R +++ b/demo/polar.R @@ -3,17 +3,16 @@ library(maps) m = map(xlim = c(-180,180), ylim = c(-90,-70), plot = FALSE, fill = TRUE) IDs <- sapply(strsplit(m$names, ":"), function(x) x[1]) library(maptools) -LL = CRS("+init=epsg:4326") +m <- map2SpatialPolygons(m, IDs=IDs, proj4string = CRS("+init=epsg:4326")) +gl = gridlines(m, easts = seq(-180,180,20)) polar = CRS("+init=epsg:3031") -m <- map2SpatialPolygons(m, IDs=IDs, proj4string = LL) -gl = gridlines(m, easts = seq(-180,180,20), ndiscr = 100) plot(spTransform(gl, polar)) plot(spTransform(m, polar), add = TRUE, col = grey(0.8, 0.8)) l = labels(gl, polar, side = 3) # pos is too simple here, use adj: l$pos = NULL text(l, adj = c(0.5, -0.3), cex = .85) -l = labels(gl, polar, side = 4) -l$srt = 0 # otherwise they end up upside-down +l = labels(gl, polar, side = 2) +l$srt = 0 # otherwise they are upside-down text(l, cex = .85) title("grid line labels on polar projection, epsg 3031") diff --git a/man/gridlines.Rd b/man/gridlines.Rd index e154b6d..5e03086 100644 --- a/man/gridlines.Rd +++ b/man/gridlines.Rd @@ -10,7 +10,7 @@ \description{ Create N-S and E-W grid lines over a geographic region; create and plot corresponding labels } \usage{ gridlines(x, easts = pretty(bbox(x)[1,]), norths = pretty(bbox(x)[2,]), - ndiscr = 20) + ndiscr = 100) gridat(x, easts = pretty(bbox(x)[1,]), norths = pretty(bbox(x)[2,]), offset = 0.5, side = "WS") \method{labels}{SpatialLines}(object, newCRS, side = 1:2, ...)