-
Notifications
You must be signed in to change notification settings - Fork 1
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
Exporting chart as PNG does not include map tiles when a provider is specified #38
Comments
Thanks for the feedback Till! Do you have a minimal reproducible example I could test against? It works for me using the following code with Altair 5.3.0, altair_tiles 0.3.0, vl-convert-python 1.3.0: import altair as alt
import altair_tiles as til
import geopandas as gpd
gdf_ne = gpd.read_file("https://naciscdn.org/naturalearth/110m/cultural/ne_110m_admin_0_countries.zip") # zipped shapefile
extent_roi = gdf_ne.loc[gdf_ne["CONTINENT"] == "Africa", ["CONTINENT", "geometry"]]
chart = (
alt.Chart(extent_roi)
.mark_geoshape(fillOpacity=0.1, stroke="green", strokeWidth=2)
.project(type="mercator")
)
chart = til.add_tiles(chart).properties(width=600, height=400)
chart.save("chart.png") By the way, if you want to increase the resolution of the PNG you get from the context menu, you can run |
Thanks for the quick response! It seems this does not work only if a provider is specified. Works for me as well with your code from above. The following however creates a chart.png without a base map. import altair as alt
import altair_tiles as til
import geopandas as gpd
gdf_ne = gpd.read_file("https://naciscdn.org/naturalearth/110m/cultural/ne_110m_admin_0_countries.zip") # zipped shapefile
extent_roi = gdf_ne.loc[gdf_ne["CONTINENT"] == "Africa", ["CONTINENT", "geometry"]]
chart = (
alt.Chart(extent_roi)
.mark_geoshape(fillOpacity=0.1, stroke="green", strokeWidth=2)
.project(type="mercator")
)
chart = til.add_tiles(chart, provider=til.providers.BaseMapDE.Grey).properties(width=600, height=400)
chart.save("chart.png") |
And thanks for the tip @binste to set the scaleFactor. Works like a charm. |
I think we're getting closer to the issue. Can you try it with a different provider such as Some context to this: Do you know by any chance which bounds are valid for BaseMapDE? I can't find anything on their website. We could then open an issue in the repo of xyzservices to include it. |
Weird, some work, some do not. It does not seem to be related to the bounds (my actual map is in Germany; just for the MRE I used your example). OpenStreetMap.HOT works |
Interesting! OpenStreetMap.BlackAndWhite seems to have been deprecated leaflet-extras/leaflet-providers#316 and also does not show up for me in a notebook but the others are weird. I've opened vega/vl-convert#162 to investigate this further, thanks again! Hope the "Save as PNG" context menu works for you in the meantime. |
This has been fixed in vl-convert-python 1.4.0. The issue was that vl-convert was failing to handle tile providers that don't include file extensions in the url. So |
Thank you very much @jonmmease!! Really appreciate it. @tillnagel could you check if this solves the issue you had with BaseMapDE.Grey? |
Works now. Great work @jonmmease! Thanks for the support and this great lib @binste! |
When using (the currently only supported vl-convert) to save a chart including altair-tiles with
my_chart.save('chart.png')
the tiles are not shown / rendered in the resulting image.Using the "Save as PNG" in the context menu works though (but low res).
The text was updated successfully, but these errors were encountered: