Skip to content

Instantly share code, notes, and snippets.

@gorshkov-leonid
Last active August 19, 2025 10:59
Show Gist options
  • Save gorshkov-leonid/1495b275f1af24e942c41c987342a26c to your computer and use it in GitHub Desktop.
Save gorshkov-leonid/1495b275f1af24e942c41c987342a26c to your computer and use it in GitHub Desktop.
geo-tricks.md

Slippy map and EPSG3857. How to get SW / NE coordinates of tile.

        // 8 / 85 / 154
        const z = 8
        const x = 85
        const y = 154
        const x0 = (x / Math.pow(2.0, z)) * 360 - 180;
        const y0 = 360 / Math.PI * Math.atan(Math.exp((180 - (y / Math.pow(2.0, z)) * 360) * Math.PI / 180)) - 90;
        const x1 =  (x + 1) / Math.pow(2.0, z) * 360 - 180;
        const y1 = 360 / Math.PI * Math.atan(Math.exp((180 - ((y + 1) / Math.pow(2.0, z)) * 360) * Math.PI / 180)) - 90;
        console.log([x0, y0], [x1, y1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment