Debian Codegraph @

demo/polar.R

raw
1 # polar projection with map:
2 library(maps)
3 m = map(xlim = c(-180,180), ylim = c(-90,-70), plot = FALSE, fill = TRUE)
4 library(sf)
5 m <- as(as(st_as_sf(m), "Spatial"), "SpatialPolygons")
6 polar = CRS("EPSG:3031")
7 gl = spTransform(gridlines(m, easts = seq(-180,180,20)), polar)
8 plot(gl)
9 plot(spTransform(m, polar), add = TRUE, col = grey(0.8, 0.8))
10 l = labels(gl, CRS("EPSG:4326"), side = 3)
11 # pos is too simple here, use adj:
12 l$pos = NULL
13 text(l, adj = c(0.5, -0.3), cex = .85)
14 l = labels(gl, CRS("EPSG:4326"), side = 2)
15 l$srt = 0 # otherwise they are upside-down
16 text(l, cex = .85)
17 title("grid line labels on polar projection, EPSG 3031")