I'm following GIBS API for Developers and I need to convert
long, lat of POI to
row of tile for given
zoom. For example to get right tile in endpoint like:
I'm using python and already tried few libs:
But didn't get right
row, col values. As I see the main problem that all of them are basing on idea that lat map direct to y and you should just divide to 180˚ and mult to 2^zoom. But actually it doesn't work and it is very easy to check.
New Zealand location is about 41° 174°. And for
zoom = 3 you should calc row that way:
row = int((90˚ + 41˚) / 180˚ * 2 ^ 3) ≈ int(5,8222) = 5 col = int((180˚ + 174˚) / 180˚ * 2 ^ 3) ≈ int(15.73333) = 15
So here you should see New Zealand:
but actually we are out of tiles. Image:
<ExceptionReport xmlns="http://www.opengis.net/ows/1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.opengis.net/ows/1.1.0/owsExceptionReport.xsd" version="1.1.0" xml:lang="en"> <Exception exceptionCode="TileOutOfRange" locator="TILECOL"> <ExceptionText>TILECOL is out of range, maximum value is 9</ExceptionText> </Exception> <Exception exceptionCode="TileOutOfRange" locator="TILEROW"> <ExceptionText>TILEROW is out of range, maximum value is 4</ExceptionText> </Exception> </ExceptionReport>
Why 4 and 9 are here?
As well for zoom = 0 it should be a whole planet on one tile, but not in NASA GIBS:
so you could ever ask row=0,col=1 tile:
Why it is so strange and where am I wrong?