Comments (9)
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.
from altair_tiles.
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 alt.renderers.set_embed_options(scaleFactor=3)
and then display the chart again (rerun the notebook cell).
from altair_tiles.
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")
from altair_tiles.
And thanks for the tip @binste to set the scaleFactor. Works like a charm.
from altair_tiles.
I think we're getting closer to the issue. Can you try it with a different provider such as OpenStreetMap.HOT
? At least in this example, the basemap is also not included when displaying the chart. I think it's because BaseMapDE
is just for Germany according to https://gdz.bkg.bund.de/index.php/default/gdz-basemapde-vektor-gdz-basemapde-vektor.html.
Some context to this: BaseMapDE
will only work if we have a map of Germany. In addition, altair_tiles
needs to ensure that only valid tiles are being loaded from the server, else no tiles at all will show up. This is happening at https://github.com/vega/altair_tiles/blob/main/altair_tiles/__init__.py#L281 in the code. However, I think right now it will even fail then, because the package xyzservices
usually provides a bounds
attribute on providers if they do not cover the whole world. However, BaseMapDE
is missing that attribute.
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.
from altair_tiles.
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
Esri.WorldGrayCanvas fails
BaseMapDE.Grey fails
OpenStreetMap.BlackAndWhite fails
OpenStreetMap.Mapnik works
from altair_tiles.
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 https://tile.openstreetmap.org/{z}/{x}/{y}.png
was working, but not https://server.arcgisonline.com/ArcGIS/rest/services/{variant}/MapServer/tile/{z}/{y}/{x}
from altair_tiles.
Thank you very much @jonmmease!! Really appreciate it.
@tillnagel could you check if this solves the issue you had with BaseMapDE.Grey?
from altair_tiles.
Works now. Great work @jonmmease! Thanks for the support and this great lib @binste!
from altair_tiles.
Related Issues (16)
- Create basemap chart without geoshape chart HOT 3
- Implement fallback if no scale value is provided HOT 1
- Add support for `fit` in `project` HOT 5
- Accept provider names as `source`
- Rethink package name and org HOT 1
- Add option to show attribution
- Thoughts on API HOT 1
- Only load tile URLs which are valid HOT 1
- Create and host documentation HOT 4
- Replace alt.Projection function argument with explicit values HOT 1
- Add support for layered charts in add_tiles
- Consider adding a default width and height for standalone tile charts
- Support concatenation HOT 2
- enable options to select a layer from a provider HOT 2
- Support python 3.8 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from altair_tiles.