我想创建这样的卫星地图:https://plotly.com/python/mapbox-layers/
我试图用我的数据(来自法国(复制这个代码:
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()
但我无法按自己的意愿缩放。
我如何选择基础地图才能获得数据区域的良好分辨率?你知道一排我可以选择以法国为中心的棒球场吗?
- 看看https://github.com/roblabs/xyz-raster-sources用于替代方案
- 已使用法国城市数据进行建筑示例,使用
https://services.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}
可以缩放到法国的建筑级别
import pandas as pd
df = pd.read_csv(
"https://gist.githubusercontent.com/curran/13d30e855d48cdd6f22acdf0afe27286/raw/0635f14817ec634833bb904a47594cc2f5f9dbf8/worldcities_clean.csv"
).loc[lambda d: d["country"].eq("France")]
import plotly.express as px
fig = px.scatter_mapbox(
df,
lat="lat",
lon="lng",
hover_name="city",
hover_data=["population"],
color_discrete_sequence=["fuchsia"],
zoom=3,
height=300,
)
# s = "https://gis.apfo.usda.gov/arcgis/rest/services/NAIP/USDA_CONUS_PRIME/ImageServer/tile/{z}/{y}/{x}"
# s = "https://basemap.nationalmap.gov/arcgis/rest/services/USGSImageryOnly/MapServer/tile/{z}/{y}/{x}"
s = "https://services.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"
fig.update_layout(
mapbox_style="white-bg",
mapbox_layers=[
{
"below": "traces",
"sourcetype": "raster",
"sourceattribution": "United States Geological Survey",
"source": [s],
}
],
)
fig.update_layout(margin={"r": 0, "t": 0, "l": 0, "b": 0})
fig.show()