How to enable the 'save' tool on a HV tilemap?

I’m trying to enable the save tool on a tilemap that has an overlaid image, with no success, the save icon does not even show up.

As usual, live colab notebook here: has a row like this:

Name                                 Value                         Type         Bounds     Mode
default_tools       ['save', 'pan', 'wheel_zoom', 'box_zo...       List       (0, None)    V RW  

If I understand it correctly, save should be turned on by default. However, no matter what I try, I can not make the save icon to appear for a map.

import holoviews as hv, bokeh as bk, numpy as np
print({'hv': hv.__version__, 'bk': bk.__version__})
left, right, top, bottom = 3490000, 3510000, 3490000, 3510000
savetest_tiles = hv.element.tiles.OSM().opts(xlim=(left, right), ylim=(top, bottom), tools=['save'])

This results in:

{'hv': '1.14.3', 'bk': '2.3.1'}

As you can see, the save icon is not displayed.

If I display some random image in itself with the ‘save’ option, it works, I even get two save icons. I don’t know why that is, but I don’t care about this right now.

savetest_image = hv.Image(np.random.rand(1,1), bounds=(left,bottom,right,top)).opts(alpha=0.4, tools=['hover', 'save'])


If I overlay the two, again, I don’t have a save icon:

savetest_combined = (savetest_tiles * savetest_image).opts(tools=['save'])


What’s curious is that in Bokeh everything works as it should:

from bokeh.plotting import figure, output_file, show
from bokeh.tile_providers import OSM, get_provider
from bokeh.models import ColumnDataSource
source = ColumnDataSource(
    data=dict(lat=[ top, top, bottom, bottom],lon=[left, right, right, left])
map = figure(x_range=(left, right), y_range=(top, bottom), 
           x_axis_type="mercator", y_axis_type="mercator")

Even if I combine multiple elements:

combined = map
combined.patch(x="lon", y="lat", fill_color="blue", fill_alpha=0.2, source=source)

I should mention that every time the save button shows up, it works as it should, there are no problems there.

Does anybody have an idea how to turn on the save tool or if HV has a bug that prevents it, how to reach the underlying Bokeh map that clearly is capable of that? Thanks!

I dealed with the same issue a while a go. As @philippjfr noted it’s due to browser security restrictions that it is not possible to save wmts tiles with the save tool. A manageable workaround is implementing a save option via file download.

That was my first guess too. But back then Bokeh itself had the same issue and it got solved (I’ve seen the ticket on github I just can’t find it now), and now it works in Bokeh, so there shouldn’t be an issue for HV either… @philippjfr, could this mean, this feature was purposefully disabled in Holoviews back then and even the issue was resolved in Bokeh, it has not been enabled? If so, is there a way to manually enable it?

I am almost 100% this issue isn’t solved in Bokeh because there is no way to solve it. I’d be very happy to be proved wrong.

Wait, I am wrong. Did seem to get solved somehow. Will make a PR to reenable it in HoloViews/GeoViews.


Wow, that is amazing, thanks a lot!

Do you have an unofficial guess at what time the new version with this feature would be released? I’m working in a project with a fixed deadline and just want to know if I have to put together a temporary fix for the time being or I could wait for it. Also, is there a hacky way to force reenabling it in the current version?

Fixed here: Reenable SaveTool for plots with TileRenderer by philippjfr · Pull Request #4922 · holoviz/holoviews · GitHub.

Could cut a release this week if you need it. Maybe ping me again in a couple of days if no release has appeared by then.


Thanks a lot, that would be perfect for me.

@philippjfr : Do you have any update on the release date of the next version with the save reenabled?

I’ll try to get that out tonight.

1 Like

I didn’t get there last night but am working on it now.

1 Like

@philippjfr : Sorry to bug you again, but do you have any updates on this?

Yes I got the release mostly ready but broken tile sources were a blocker. There’s now a PR up with the required deprecations and I should be able to release tonight or early tomorrow.

1 Like

@SteveAKopias The release is now available on pip and the pyviz channel in conda. It’ll get updated in conda-forge and conda defaults in the coming days.

1 Like

Awesome, thank you, it works!

One problem though, it adds a black bar where the toolbar is.

This is how the top of the site itself looks like:

And this is how the top of the saved image looks like:

The same this happens if the toolbar is at the default position, just at the right.

Nowhere in my CSS or style options do I set black as background-color, so I don’t even know where it comes from, but also, this shouldn’t even be visible. Is there any way to tweak the captured area?

Inclined to say that’s your PNG viewer, because I can’t reproduce.

That said you could try adding .opts(hooks=[lambda p, _: p.state.update(border_fill_color=None)]) to make the border color transparent.

Turns out the black came from a border_fill_alpha=0 setting, so it was actually already transparent and indeed the viewer default was to present it as black as it often would be the case for the visitors too. I’ve changed it to 1 and to border_fill_color='white' (or for the sake of showing it here to yellow) and it is much better, but the the problem is that the bar is still there.

Here is an easy to reproduce example:

  hv.opts.Tiles(tools=['save'], width=400, xaxis=None, yaxis=None, border=0, margin=0)
map_white = hv.element.tiles.OSM().opts(hooks=[lambda p, _: p.state.update(border_fill_color='white')])
map_none = hv.element.tiles.OSM().opts(hooks=[lambda p, _: p.state.update(border_fill_color=None)])
display (map_white)
display (map_none)

It displays:

(I don’t know why there are two save icons per map, and it’s weird as both first icons save the first map and both second icons save the second map if I’m correct, but I don’t care about that right now.)

If I save them, I get these:
bokeh_plot (20)
bokeh_plot (20)
You can’t see it on a white background here, but both of them has about 30px wide extra space on the right side, either white or transparent and that’s what I’m trying to get rid of.

Not sure what can be done about that tbh, disabling the toolbar would get rid of that white space but then you couldn’t use the save tool.

1 Like