holoviz / geoviews

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

Hover tooltips gv.RGB does not work, return ??? #331

Closed emryslda closed 5 years ago

emryslda commented 5 years ago

Hy guys I am trying to plot an RGB image with geoviews using also the hover tooltips to display the Lat e Lon and RGB values.

1)

opt.default(opts.RGB( tools=['hover']))
rgb =gv.RGB((RGB['x'],RGB['y'],RGB.R,RGB.G, RGB.B),vdims=['R','G','B'], crs=crs)

where RGB is an xarray with R,G,B, Data Variables. Should I pass to gv.RGB another object? The plot is ok.

2

2) for Lat e Lon coords I report another issue: if you use the following tooltips, you will get the right value but in meters.

tooltips=[
    ("lon", "$x"),
    ("lat", "$y")
   ]

if you use the CustomJSHover code, you will get the wrong projected value but in degrees and with a lot of digit after the comma that would be nice to cut.

lat_custom = CustomJSHover(code="""
    var projections = require("core/util/projections");
    var x = special_vars.x
    var y = special_vars.y
    var coords = projections.wgs84_mercator.inverse([x, y])
    return "" + coords[0]
""")

hover=HoverTool(
    tooltips=[( 'lat','@y{custom}' )],
    formatters=dict(y=lat_custom)
)

any idea?

philippjfr commented 5 years ago

Should have been fixed by:

https://github.com/pyviz/holoviews/pull/3727

philippjfr commented 5 years ago

The second issue is already being discussed here: https://github.com/pyviz/geoviews/issues/251