Created
July 31, 2015 13:07
-
-
Save geotheory/2b921aff20b5579793ec to your computer and use it in GitHub Desktop.
Get aspect ratio for a small-area lat-long dataset to approximate Mercator projection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ref: http://stackoverflow.com/questions/31745894/get-aspect-ratio-for-lat-long-plots/31746542#31746542 | |
# requires ggplot2 | |
map_aspect = function(x, y) { | |
x.center <- sum(range(x)) / 2 | |
y.center <- sum(range(y)) / 2 | |
x.dist <- ggplot2:::dist_central_angle(x.center + c(-0.5, 0.5), rep(y.center, 2)) | |
y.dist <- ggplot2:::dist_central_angle(rep(x.center, 2), y.center + c(-0.5, 0.5)) | |
y.dist / x.dist | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment