Skip to content

Commit

Permalink
change default ndiscr; tidy docs & demo
Browse files Browse the repository at this point in the history
  • Loading branch information
edzer committed Feb 3, 2016
1 parent 979110a commit 0338cdb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion R/gridlines.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 4 additions & 5 deletions demo/polar.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
2 changes: 1 addition & 1 deletion man/gridlines.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -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, ...)
Expand Down

0 comments on commit 0338cdb

Please sign in to comment.