Reputation: 485
I'm brand new to MapBox, but like the images it produces, and want to be able to use their API to render some GPS points nicely.
Given a Standard GPS point (and a MapBox zoom level), how can I find the Lon/Lat values for a suitable MapBox 'tile' ?
The actual code that I'm trying to use is the Python code at:
https://github.com/mapbox/mapbox-sdk-py/blob/master/docs/static.md#static-maps
And my starting GPS point is in Auckland New Zealand -36.8,174.7
.
https://www.google.co.nz/maps/place/36°48'00.0"S+174°42'00.0"E/
I have naively tried entering "standard" GPS coordinates:
from mapbox import Static
service = Static()
response = service.image('mapbox.satellite', lon=-36.8, lat=174.7, z=10)
but this results in the error message:
mapbox.errors.InvalidCoordError: Latitude must be between -85.0511 and 85.0511
Searching for this error message led me to this:
https://en.wikipedia.org/wiki/Tiled_web_map
But I still have no idea how to determine the long/lat values of a suitable tile. Any help would be appreciated.
Thanks in Advance
Patrick
Upvotes: 1
Views: 964
Reputation: 676
The error message indeed right: mapbox.errors.InvalidCoordError: Latitude must be between -85.0511 and 85.0511
You got your coordinates reversed. The following coordinates -36.8, 174.7 stand for Latitude and Longitude, and not the other way around. So your code should be: service.image('mapbox.satellite', lon=174.7 lat=-36.8, z=10
)
This can be seen from your Google Maps link: https://www.google.co.nz/maps/place/36°48'00.0"S+174°42'00.0"E/. Latitude guides you from South (negative) to North (positive). Longitude guides you from East (positive) to West (negative). Pay attention the Google link says: 36°48'00.0"S
+174°42'00.0"E`. More information available here https://en.wikipedia.org/wiki/Geographic_coordinate_system
Searching for this error message led me to this:
https://en.wikipedia.org/wiki/Tiled_web_map
But I still have no idea how to determine the long/lat values of a suitable tile. Any help would be appreciated.
Thanks in Advance
You don't need to. Mapbox's API abstracts that away for you. Take a look here: https://www.mapbox.com/api-documentation/#retrieve-a-static-map-from-a-style
Upvotes: 2