1

I'm trying to use geoviews to display a path. I can get it to display ONLY the points properly:

import numpy as np
import geoviews as gv
import cartopy.crs as ccrs
import pandas as pd

hv.extension('bokeh')

coord_system = ccrs.UTM(17)

userLine = [[ 501386.89237725, 3026047.23276743],
 [ 502233.40219658, 3030363.86891928],
 [ 497065.22714886, 3031309.6654351 ],
 [ 499260.08171301, 3027147.9437062 ],
 [ 494678.08475863, 3026891.08691589],
 [ 494971.32963864, 3025188.1383645 ],
 [ 496475.86909916, 3025394.03293946],
 [ 496061.07730504, 3026116.58492655],
 [ 497530.90995815, 3026357.00292598]]

line_pd = pd.DataFrame(userLine, columns=['Longitude', 'Latitude'])
pressure = pd.DataFrame(np.arange(0,401,np.ceil(401/len(userLine))), columns=['Pressure'])
windspeed = pd.DataFrame(np.arange(0,201,np.ceil(201/len(userLine))), columns=['Max_Wind_Speed'])
alldata = pd.concat([line_pd,pressure,windspeed], axis=1)

gvdata = gv.Dataset(alldata, kdims=['Pressure','Max_Wind_Speed','Longitude','Latitude'])
hover = HoverTool(tooltips=[("Longitude", "@Longitude"), ("Latitude", "@Latitude"), ("Pressure","@Pressure"),("Max Wind Speed","@Max_Wind_Speed")])

%%opts Points (size=10 cmap='inferno') [tools=[hover] color_index=4]
gvdata.to(gv.Points, kdims=['Longitude', 'Latitude'], vdims=['Pressure','Max_Wind_Speed'], crs=coord_system)

But what I really want is a path. However, when I try:

gvdata.to(gv.Path, kdims=['Longitude', 'Latitude'], crs=coord_system)

I get the error message DataError: None of the available storage backends were able to support the supplied data format.

I have tried reformatting the input data, but no success. I'm not sure what else I could be doing wrong.

kcp
  • 45
  • 8

1 Answers1

3

The .to method has the purpose of letting you easily group high-dimensional data. In this particular example you have only two dimensions (latitude and longitude) so there is no need to use .to. In your particular example this should be sufficient to construct the plot:

gv.Path([userLine], crs=coord_system)

Path types in HoloViews can be constructed using a list of arrays, dataframes or dictionary of columns, so this would also work:

line_pd = pd.DataFrame(userLine, columns=['Longitude', 'Latitude'])
gv.Path([line_pd], crs=coord_system)

Edit: In your expanded example the format that works for me is as follows:

%%opts Path (cmap='inferno') [tools=[hover] color_index='Max_Wind_Speed']
gv.Path([alldata], vdims=['Pressure','Max_Wind_Speed'], crs=coord_system)
philippjfr
  • 3,997
  • 14
  • 15
  • This is dumbed down example of my 'real' problem. In the real problem I have a couple of other dimension that I'm displaying with HoverTool. In that case, would I need to use the `.to` method? – kcp Mar 09 '18 at 17:19
  • Could you elaborate on what you are trying to achieve? Currently Path types do not interact that well with ``.to`` but based on your current description I don't know if you need it yet. – philippjfr Mar 09 '18 at 17:22
  • I edited the question to add the additional dimensions. I'm creating a custom hover so that I can feed it the true lat/lon values but I didn't copy that part into the example. – kcp Mar 09 '18 at 17:33
  • And to elaborate further, I'm basically allowing a user to click out a custom hurricane path on a map, then via a dynamic table, apply wind speed and pressure to each data point on the path, which would then color code the point on the maps based on the magnitudes entered. This is just the first setup (actually, I had to backtrack/simplify because dynamic tables were giving me major headaches) – kcp Mar 09 '18 at 17:37
  • I've now edited my answer to show how to plot the Path colored by the 'Max_Wind_Speed'. Let me know if that's what you were trying to achieve. – philippjfr Mar 09 '18 at 17:40
  • That's almost it. The only thing is that the hover only has the Max_Wind_Speed linked to the original data correctly. The others all display ???. – kcp Mar 09 '18 at 17:47
  • Unfortunately that appears to be a bug, see https://github.com/ioam/holoviews/issues/2427 to follow the progress. – philippjfr Mar 09 '18 at 18:22
  • Got it. In the meantime, would you recommend the `.to` method as a workaround or some other approach? – kcp Mar 09 '18 at 18:38
  • I'd probably suggest you disable the hover on the Path and instead overlay the points, which should support the hover just fine. – philippjfr Mar 09 '18 at 18:51
  • Got it. Thanks for your help!! – kcp Mar 09 '18 at 18:59
  • this now throws the error `ValueError: Unsupported geometry type 'GeometryCollection'` Do you know what changed? – kcp Jun 04 '18 at 15:39
  • Probably a regression on GeoViews master, should be fixed now. – philippjfr Jun 05 '18 at 03:25