Skip to content

Instantly share code, notes, and snippets.

@mdsumner
Last active July 11, 2026 13:15
Show Gist options
  • Select an option

  • Save mdsumner/669dcdc6ca06a2c355053b16374b7e30 to your computer and use it in GitHub Desktop.

Select an option

Save mdsumner/669dcdc6ca06a2c355053b16374b7e30 to your computer and use it in GitHub Desktop.
a rough stab at the triangle map going around
xy <- do.call(cbind, maps::map(plot = F)[1:2])

mm <- matrix(c(8L, -95L, -50L, 59L, -47L, -62L), ncol = 2)
mm <- rbind(mm, mm[1, ])
n <- nrow(mm)
x <- 1:n
idx <- seq(1, n, length.out = 200 )
par(mfrow = c(2, 1))
maps::map()
polypath(triangle <- cbind(approxfun(x, mm[,1])(idx), approxfun(x, mm[,2])(idx)), col = scales::alpha("firebrick", .5), lwd = 2)

omerc <- "+proj=omerc +lonc=-26 +lat_0=0 +gamma=-35"
xl <- yl <- c(-1, 1) * pi * 6378137 * .5
plot(reproj::reproj(xy, omerc), pch = ".", xlim = xl, ylim = yl, asp = 1)
polypath(reproj::reproj(triangle, omerc), col = scales::alpha("firebrick", .5), lwd = 2)
@mdsumner

Copy link
Copy Markdown
Author
image

@mdsumner

Copy link
Copy Markdown
Author

a variant

xy <- do.call(cbind, maps::map(plot = F)[1:2])

mm <- matrix(c(8L, -95L, -50L, 59L, -47L, -62L), ncol = 2)
mm <- rbind(mm, mm[1, ])
n <- nrow(mm)
x <- 1:n
idx <- seq(1, n, length.out = 200 )
par(mfrow = c(2, 1), mar = rep(.1, 4))
maps::map()
polypath(triangle <- cbind(approxfun(x, mm[,1])(idx), approxfun(x, mm[,2])(idx)), col = scales::alpha("firebrick", .5), lwd = 2)

omerc <- "+proj=omerc +lonc=-26 +lat_0=0 +gamma=-35"
xl <- yl <- c(-1, 1) * pi * 6378137 * .5
plot(reproj::reproj(xy, omerc), pch = ".", xlim = xl, ylim = yl, asp = 1)
polypath(reproj::reproj(triangle, omerc), col = scales::alpha("firebrick", .5), lwd = 2)
g <- graticule(seq(-180, 175, by = 15), seq(-85, 85, by = 10))
sp <- terra::vect(g)
plot(project(sp, omerc), add = T, col = "grey", lty = 2)
plot(project(sp, omerc), add = T, col = "darkgrey", lty = 2)
image

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