I use Python
for plotting geospatial data on maps.
For certain map-styles, such as ["basic", "streets", "outdoors", "light", "dark", "satellite", "satellite-streets"]
, I need a mapbox-access token and for some geospatial plotting packages like folium
I even need to create my own link for retrieving the map-tiles.
So far, it worked great with the style "satellite"
:
mapbox_style = "satellite"
mapbox_access_token = "....blabla"
request_link = f"https://api.mapbox.com/v4/mapbox.{mapbox_style}/{{z}}/{{x}}/{{y}}@2x.jpg90?access_token={mapbox_access_token}"
However, when choosing "satellite-streets"
as mapbox-tile-ID, the output doesn't show a background map anymore. It fails with inserting "satellite-streets", "satellitestreets" and "satellite_streets"
into the aforementioned link-string.
Why is that and how can I come to know what's the correct tile-ID-name for "satellite-streets"
?
I found an answer when reaching out to the customer support. Apparently, one has to access the static APIs which have specific names listed on their website:
"In general, the styles that you mentioned including "satellite_streets" that you are referencing are our classic styles that are going to be deprecated starting June 1st. I would recommend using our modern static API the equivalent modern styles. This will allow you to see the most updated street data as well.
Like the example request below:
https://api.mapbox.com/styles/v1/mapbox/satellite-streets-v11/tiles/1/1/0?access_token={your_token}
Here is more info on the deprecation of the classic styles and the migration guide for them."
My personal adaptation after having tried everything out myself, is:
Via combining the above-mentioned with the details on how to construct a Mapbox-request link on this documention from mapbox' website, I finally managed to make it work.
An example request looks like so (in python using f-strings):
mapbox_tile_URL = f"https://api.mapbox.com/styles/v1/mapbox/{tileset_ID_str}/tiles/{tilesize_pixels}/{{z}}/{{x}}/{{y}}@2x?access_token={mapbox_access_token}"
The tileset_ID_str could be e.g. "satellite-streets-v11"
which can be seen at the following link containing valid static maps.