Bring Drag & Drop to Dash with Dashboard Engine. 💫 Learn how at our next webinar!

Import Mapbox Layer ".mbtiles" format

Hi guys,
I am trying to import a layer, but the file format is “mbtiles”.

To do it, I followed the example on the web, but its not working, because it does not have this “sourcetype option”.

Is it possible to plot this tile? or is it possible to convert it to a valid format?

import pandas as pd
us_cities = pd.read_csv("https://raw.githubusercontent.com/plotly/datasets/master/us-cities-top-1k.csv")

import plotly.express as px

fig = px.scatter_mapbox(us_cities, lat="lat", lon="lon", hover_name="City", hover_data=["State", "Population"],
                        color_discrete_sequence=["fuchsia"], zoom=3, height=300)
fig.update_layout(
    mapbox_style="white-bg",
    mapbox_layers=[
        {
            "below": 'traces',
            "sourcetype": "raster",
            "sourceattribution": "United States Geological Survey",
            "source": [
                "https://basemap.nationalmap.gov/arcgis/rest/services/USGSImageryOnly/MapServer/tile/{z}/{y}/{x}"
            ]
        }
      ])
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
fig.show()

You will need a server app for the mbtiles file(s) to convert into the correct tiled map format. This will be png for raster or .mvt for vector tiles. Alternatively, you can export files into a tile directory on file system and serve that.