cartopy.io.img_tiles.MapboxStyleTiles#

class cartopy.io.img_tiles.MapboxStyleTiles(access_token, username, map_id, desired_tile_form='RGB', cache=False)[source]#

Set up a new instance to retrieve tiles from a Mapbox style.

Access to Mapbox web services requires an access token and a map ID. See https://www.mapbox.com/api-documentation/ for details.

For more details on Mapbox styles, see https://www.mapbox.com/studio-manual/overview/map-styling/.

For terms of service, see https://www.mapbox.com/tos/.

Parameters:
  • access_token – A valid Mapbox API access token.

  • username – The username for the Mapbox user who defined the Mapbox style.

  • map_id – A map ID for a map defined by a Mapbox style. This is the map whose tiles will be retrieved through this process. Note that this style may be private and if your access token does not have permissions to view this style, then map tile retrieval will fail.

  • desired_tile_form (str, optional) – The desired format of the tile (defaults to “RGB”).

  • cache (bool or pathlib.Path or str, optional) – To allow offline use, as well as not spam tile providers, Cartopy can create a local cache of previously fetched tiles. The default path is cartopy.config["cache_dir"]. If it is set to True, the default path is used. If it is set to a custom path, then this path is used instead of the default one. If it is set to False, the tiles are downloaded each time.

find_images(target_domain, target_z, start_tile=(0, 0, 0))#

Target domain is a shapely polygon in native coordinates.

tile_bbox(x, y, z, y0_at_north_pole=True)#

The (x0, x1), (y0, y1) bounding box for the given tile position.

Parameters:
  • x (int) – The x tile coordinate in the Google tile numbering system.

  • y (int) – The y tile coordinate in the Google tile numbering system.

  • z (int) – The z tile coordinate in the Google tile numbering system.

  • y0_at_north_pole (bool, optional) – Boolean representing whether the numbering of the y coordinate starts at the north pole (as is the convention for Google tiles) or not (in which case it will start at the south pole, as is the convention for TMS). Defaults to True.

tileextent(x_y_z)#

Return extent tuple (x0,x1,y0,y1) in Mercator coordinates.