This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

How to calculate north east lat/lon coordinates of a tile?

0

HI there! I know the below code calculates the north west corner long/lat coordinates of a tile, but is there a way to calculate the north east, south east or south west corner long/lat coordinates? (I'm terrible at maths...).

I'm programming in java, and any zoom around 17 - 19 would do.

static double tile2lon(int x, int z) { return x / Math.pow(2.0, z) * 360.0 - 180; }

static double tile2lat(int y, int z) { double n = Math.PI - (2.0 * Math.PI * y) / Math.pow(2.0, z); return Math.toDegrees(Math.atan(Math.sinh(n))); }

Thank you very much!

asked 30 May '19, 02:18

xj18205's gravatar image

xj18205
36112
accept rate: 0%


One Answer:

1

I just realised I can use the NW corner of the surround tiles to work out this answer!

answered 30 May '19, 03:06

xj18205's gravatar image

xj18205
36112
accept rate: 0%

Source code available on GitHub .