Skip to content

Add more projection options to Mapbox map layers in Python #4189

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wybert opened this issue May 4, 2023 · 1 comment
Closed

Add more projection options to Mapbox map layers in Python #4189

wybert opened this issue May 4, 2023 · 1 comment

Comments

@wybert
Copy link

wybert commented May 4, 2023

Hi, I would like to see projection support in Mapbox map layers like, px.scatter_mapbox, such as 'globe' projection (which will make a tile-based 3d globe map). I noticed that Plotly is integrated with Mapbox-gl, and the Mapbox-GL support different projections, so it should be easy to have this option in Plotly. It looks like it's already supported in scatter_geo (see the doc)but not Mapbox layers.

See projections support in Mapbox-GL here. See what's looks like with projection here,
image
image

The code by the support the function should look like,

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}, projection= 'globe')
fig.show()

the projection option can be configured to support more projections

@alexcjohnson
Copy link
Collaborator

duplicate of plotly/plotly.js#6591, I'll comment over there.

@alexcjohnson alexcjohnson closed this as not planned Won't fix, can't repro, duplicate, stale May 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants