Skip to content

Instantly share code, notes, and snippets.

@mdsumner
Created January 11, 2023 18:58
Show Gist options
  • Save mdsumner/30ad75d1c6b03b020ab5a43518aa5ab4 to your computer and use it in GitHub Desktop.
Save mdsumner/30ad75d1c6b03b020ab5a43518aa5ab4 to your computer and use it in GitHub Desktop.
library(graticule)
lons <- seq(-80, -40, by = 5)
lats <- seq(77, 84.5, by = .5)
latpts <- cbind(min(lons), lats)
lonpts <- cbind(lons, min(lats))

prj <- "+proj=laea +lat_0=90 +lon_0=-60"
xy_lon <- sf::sf_project(pts = lonpts, to = prj, from = "OGC:CRS84")
xy_lat <- sf::sf_project(pts = latpts, to = prj, from = "OGC:CRS84")
g <- graticule(lons,lats, proj = prj)
plot(g)

lonlab <- function(x) paste(x, ifelse(x >0, "E", "W"))
latlab <- function(x) paste(x, ifelse(x >0, "N", "S"))

text(xy_lon, lab = lonlab(lonpts[,1]), pos = 1, offset = 1)
text(xy_lat, lab = latlab(latpts[,2]), pos = 1, offset = -4)
@PMassicotte
Copy link

I hear you :) I will certainly have a look at whatarelief soon and integrate it to my workflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment