0
votes

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
import plotly.express as px

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

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()
1
When I run the above code, there is no error, what is the problem? - r-beginners

1 Answers

0
votes

Plotly internally uses Mapbox GL JS and Mapbox GL JS does not support to directly use mbtiles format.

I followed the example on the web Which document did you refer to?