Last active
August 29, 2023 15:33
-
-
Save pianosnake/c67c8ddd931c929dfdaed3696f6664e0 to your computer and use it in GitHub Desktop.
Calculate the width of one degree in meters at a given latitude on Earth
This file contains hidden or 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
const EARTH_CIR_METERS = 40075016.686; | |
function toRadians(degrees) { | |
return degrees * Math.PI / 180; | |
}; | |
function degreeWidth(lat){ | |
return EARTH_CIR_METERS / 360 * Math.cos(toRadians(lat)); | |
} | |
//example | |
const atEquator = degreeWidth(0); // 111319.490 meters | |
const atDenver = degreeWidth(39.73); // 85611.923 meters | |
const atChicago = degreeWidth(41.88); // 82882.3277 meters | |
const atNorthPole = degreeWidth(90); // ~0 m | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment