holoviz / geoviews

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

Incorrect values of lat/lon on hover using latest version #347

Closed hdsingh closed 5 years ago

hdsingh commented 5 years ago

Correct hover values in hv.__version__: 1.12.1: Screenshot from 2019-08-09 12-03-24

Incorrect hover values in hv.__version__: 1.12.4: Screenshot from 2019-08-09 12-03-41

Reproducible example:

import xarray as xr
import hvplot.xarray
import holoviews as hv
import cartopy.crs as ccrs
print("hv.__version__: ",hv.__version__)

url = 'http://opendap.co-ops.nos.noaa.gov/thredds/dodsC/NOAA/LOOFS/MODELS/201907/glofs.loofs.fields.forecast.20190720.t06z.nc'
data = xr.open_dataset(url)
data = data.set_coords(['lat','lon'])

mesh = data.air_u[-1:,:,:].hvplot.quadmesh(x='lon', y='lat', rasterize=True, crs=ccrs.PlateCarree())
mesh

Also correct behaviour is shown without using crs.

fmaussion commented 5 years ago

I've been hit by this as well. As a workaround I wanted to create a custom hover showing the z values only.

I have a vg.dataset looking as following:

dataset = gv.Dataset(ds, ['longitude', 'latitude'], 'trends', crs=crs.PlateCarree())
print(dataset)
:Dataset   [longitude,latitude]   (trends)

But when I create a custom hover, the values are not shown and I see a ??? instead:

from bokeh.models import HoverTool
hover = HoverTool(
        tooltips=[
            ("Trend", "@trends"),
        ]
    )

image = dataset.to(gv.Image).redim.range(trends=(-1.5, 1.5))
plot = image.opts(cmap='RdBu_r', colorbar=True, width=1000, height=500, 
                  projection=crs.Mollweide(), tools=[hover], active_tools=['pan','wheel_zoom']) * gf.coastline
plot

Selection_034

It's probably me doing something wrong here, but what?

fmaussion commented 5 years ago

Nevermind my question above, this seems to not yet be supported in Holoviews.

Using @image works (took me some time to find out)

rsignell-usgs commented 5 years ago

@jbednar , I'm hoping this is on the list of tasks to be done for Pangeo. We would really like to stop pinning holoviews to 1.12.1.

jsignell commented 5 years ago

As a workaround, adding the projection arg seemed to fix this for me. The projection arg is meant to specify the target projection of the plot.

import xarray as xr
import hvplot.xarray
import holoviews as hv
import cartopy.crs as ccrs
print("hv.__version__: ",hv.__version__)

url = 'http://opendap.co-ops.nos.noaa.gov/thredds/dodsC/NOAA/LOOFS/MODELS/201907/glofs.loofs.fields.forecast.20190720.t06z.nc'
data = xr.open_dataset(url)
data = data.set_coords(['lat','lon'])

mesh = data.air_u[-1:,:,:].hvplot.quadmesh(x='lon', y='lat', rasterize=True, 
                                           crs=ccrs.PlateCarree(), projection=ccrs.PlateCarree())
mesh
Screen Shot 2019-09-18 at 5 06 37 PM
philippjfr commented 5 years ago

So using latest holoviews and geoviews I actually can't reproduce this.

philippjfr commented 5 years ago

@jsignell Could you confirm?

philippjfr commented 5 years ago

Huh, very strange, suddenly I can reproduce it again.

jsignell commented 5 years ago

Maybe you left off rasterize=True?

philippjfr commented 5 years ago

So the very strange thing here is that it all seems to be set up correctly and it works when you do:

pn.panel(hv.render(mesh))

But somehow when letting HoloViews render it, the CustomJSHover does not get called.

tom-andersson commented 3 years ago

I'm getting the same hover issue (lat/lon show up as projected coords, not in degrees) with hvplot=0.7.2, geoviews=1.9.1, bokeh=2.3.0. I see from digging through issues like this that the bug was meant to be fixed a couple years ago. Any advice?