Eli*_*369 1 python maps satellite plotly
我想创建这样的卫星地图: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()
Run Code Online (Sandbox Code Playgroud)
但我无法按我想要的方式缩放。
我如何选择底图以获得数据区域的良好分辨率?您是否知道一组底图,我可以从中选择一张以法国为中心的底图?
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()
Run Code Online (Sandbox Code Playgroud)