holoviz / geoviews

Simple, concise geographical visualization in Python
http://geoviews.org
BSD 3-Clause "New" or "Revised" License
578 stars 75 forks source link

hover info on geoviews plots #100

Closed suvarchal closed 6 years ago

suvarchal commented 6 years ago

Thanks to latest geoviews, Latitude, Longitude axis labels are now formatted nicely.

I made a QuadMesh of a Image to make it "hoverable". As you can see from the image below, the hover information does not reflect values on the axis.

image

Furthermore, when i make the above plot as a source to a holoviews streams element(eg., streams.SingleTap) the x,y values passed are from the hover information not the ones on axis labels that i would expect.

I was educated by @philippjfr in an another issue, those values represent meters of projection, as a fix i could invert them to degrees but I think it is desirable to use lat,lon values as degrees on hover and as values passes to streams?

suvarchal commented 6 years ago

I also wonder (also to asses my capabilities to contribute) what is approach taken by geoviews to support more projections via bokeh backend. is it like widgets on top of matplotlib/cartopy backend or build something from scratch?

pallenmar commented 6 years ago

Sorry I'm having the same issue on this as well. Could you explain the quick fix when converting them to degrees? Thank you so much!

philippjfr commented 6 years ago

The issue here is that data plotted using bokeh will always be projected to Mercator coordinates, which means that if we want to display the latitude and longitude values, we have to send both the transformed and original coordinates which would almost double the amount of data that is sent to the browser. For the time being I'd suggest passing a custom HoverTool that displays only the value column:

hover = HoverTool(tooltips=[("z", "${z}")])
hv.QuadMesh(...).opts(plot=dict(tools=[hover]))

In future we can consider sending the longitude and latitude values as well, I'm just not convinced it should do so by default.

jbednar commented 6 years ago

Just to clarify, it sounds like what you are saying is that right now we send only the Web Mercator version of the data into the browser, and for hover to show lon,lat we'd have to send another entire copy of the data, in lon,lat coordinates? If so, it does seem like we should not enable that by default, but it also seems like we should make it easy to enable it when desired, as a 2X penalty may be no problem in many cases, and the Mercator hover coordinates are definitely not useful.

To avoid the duplicate data, can we not use a similar remapping approach as we do for the axes, transforming the Mercator coordinates back into lon,lat with some JS code in the hover support?

philippjfr commented 6 years ago

To avoid the duplicate data, can we not use a similar remapping approach as we do for the axes, transforming the Mercator coordinates back into lon,lat with some JS code in the hover support?

I always assumed that HoverTools only support specific types of formatters but it actually turns out that yes, they do support the MercatorTickFormatter. So this should be straightforward to fix actually.

philippjfr commented 6 years ago

Actually seems I was right afterall, the only supported formatters for the HoverTool are 'numeral', 'datetime' and 'printf'.

jbednar commented 6 years ago

Can you raise an issue on Bokeh about this? People (including me!) really, really do want to be able to read off lon,lat coordinates from a hover, so that they can record the locations of interesting data points and construct various queries on the original lon,lat data.

scaine1 commented 6 years ago

The issue here is that data plotted using bokeh will always be projected to Mercator coordinates, which means that if we want to display the latitude and longitude values, we have to send both the transformed and original coordinates which would almost double the amount of data that is sent to the browser.

Would it be possible to include the proj4 transform into the html/broswer, so that the browser could transform the data back to lat/lon during the hover? That would remove the issue of having to almost double the data. However, I have no idea how this would be done..I am guessing that there might need to be modifications on the bokeh side? I do note that there is a proj4js library..

philippjfr commented 6 years ago

I don't think that's even necessary, the Web Mercator -> Lat/Lon conversion is relatively straightforward, I just don't think bokeh currently provides a way to apply custom formatters to the hover tool.

scaine1 commented 6 years ago

Thanks for clearing that up philippjfr. I have created a feature request with bokeh https://github.com/bokeh/bokeh/issues/7647