File: polar.R

package info (click to toggle)
r-cran-sp 1%3A2.2-0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,856 kB
  • sloc: ansic: 1,091; sh: 14; makefile: 2
file content (17 lines) | stat: -rw-r--r-- 637 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# polar projection with map:
library(maps)
m = map(xlim = c(-180,180), ylim = c(-90,-70), plot = FALSE, fill = TRUE)
library(sf)
m <- as(as(st_as_sf(m), "Spatial"), "SpatialPolygons")
polar = CRS("EPSG:3031")
gl = spTransform(gridlines(m, easts = seq(-180,180,20)), polar)
plot(gl)
plot(spTransform(m, polar), add = TRUE, col = grey(0.8, 0.8))
l = labels(gl, CRS("EPSG:4326"), 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, CRS("EPSG:4326"), side = 2)
l$srt = 0 # otherwise they are upside-down
text(l, cex = .85)
title("grid line labels on polar projection, EPSG 3031")