我正在使用plotly的Scattermapbox将地图与由datashader的阴影函数创建的多边形的阴影图像覆盖(基于https://plotly.com/python/datashader/),但投影似乎没有对齐,请参见下图。有什么建议我可以使用plotly的Scattermapbox和datashader来克服这个问题吗?
可重现的例子:
import geopandas as gpd
import plotly.graph_objects as go
import spatialpandas as spd
import datashader as ds
from colorcet import fire
import datashader.transfer_functions as tf
# load data
world = gpd.read_file(
gpd.datasets.get_path('naturalearth_lowres')
)
# world = world.to_crs(epsg=3857)
# create spatialpandas DataFrame
df_world = spd.GeoDataFrame(world)
# create datashader canvas and aggregate
cvs = ds.Canvas(plot_width=1000, plot_height=1000)
agg = cvs.polygons(df_world, geometry='geometry', agg=ds.mean('pop_est'))
# create shaded image
tf.shade(agg, cmap=fire)
Run Code Online (Sandbox Code Playgroud)
# create shaded image and convert to Python image
img = …Run Code Online (Sandbox Code Playgroud)