Skip to content
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

altair_tiles: Tiles are missing in PNG export but works with SVG #162

Closed
binste opened this issue Apr 14, 2024 · 2 comments · Fixed by #163
Closed

altair_tiles: Tiles are missing in PNG export but works with SVG #162

binste opened this issue Apr 14, 2024 · 2 comments · Fixed by #163

Comments

@binste
Copy link

binste commented Apr 14, 2024

In vega/altair_tiles#38 it came up that for certain tile providers, the tiles are missing in an exported PNG but they show up in a Jupyter notebook and in an SVG chart.

Minimal example

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.Esri.WorldGrayCanvas).properties(
    width=600, height=400
)
chart

Chart displays as expected with tiles:

image

When saving to SVG and PNG, only the SVG image shows the tiles so seems like they get lost when downloading and embedding them.

chart.save("chart.svg")
chart.save("chart.png")

If you switch the provider in the above example to til.providers.OpenStreetMap.Mapnik, the tiles also show up in PNG. Sorry I don't know how to debug this any further but maybe it's something related to #63 where certain providers require specific request headers or so? In #64 you mentioned that we could set RUST_LOG to vl_convert but at least in a notebook, nothing shows up and I don't have cargo set up to install the CLI.

@jonmmease
Copy link
Collaborator

Thanks for the report, I'll take a look!

@jonmmease
Copy link
Collaborator

Fix released in version 1.4.0

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

Successfully merging a pull request may close this issue.

2 participants