# Xarray and Panel -selecting location on Map

**URL:** <https://discourse.pangeo.io/t/xarray-and-panel-selecting-location-on-map/1564>\
**Category:** Visualization\
**Created:** [June 17, 2021, 7:10pm UTC](https://discourse.pangeo.io/t/xarray-and-panel-selecting-location-on-map/1564 "2021-06-17T19:10:15Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![khider](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pangeo.io/khider/32/613_2.png) [@khider](https://discourse.pangeo.io/u/khider)\
**Post date:** [June 17, 2021, 7:10pm UTC](https://discourse.pangeo.io/t/xarray-and-panel-selecting-location-on-map/1564/1 "2021-06-17T19:10:16Z")

</div>

Trying to create a simple dashboard showing the map data and a time series underneath, dashboard controls should allow selecting a dataset and run some simple analysis and show the results. Ran into a few hiccups and was wondering if anyone had solved them:

1. When creating a time slider with xarray.dataarray.hvplot(), I can’t incorporate the results in a panel. The panel controls don’t work.
2. Can’t get a time sliders from the Param class. I’ve been using the widgets class but lose all the advantages of Param.
3. Is there a way to use the tools ‘tap’ to get the coordinates and show a timeseries for these coordinates?

Thank you

Deborah

---

<div class="post-metadata">

**Author:** ![rabernat](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pangeo.io/rabernat/32/22_2.png) [@rabernat](https://discourse.pangeo.io/u/rabernat)\
**Post date:** [June 18, 2021, 1:56pm UTC](https://discourse.pangeo.io/t/xarray-and-panel-selecting-location-on-map/1564/2 "2021-06-18T13:56:31Z")

</div>

Thanks for the interesting question @khider! Pinging @jbednar as our resident panel / holoviews expert.

---

<div class="post-metadata">

**Author:** ![cisaacstern](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pangeo.io/cisaacstern/32/909_2.png) [@cisaacstern](https://discourse.pangeo.io/u/cisaacstern)\
**Post date:** [June 21, 2021, 2:35pm UTC](https://discourse.pangeo.io/t/xarray-and-panel-selecting-location-on-map/1564/3 "2021-06-21T14:35:56Z")

</div>

@khider, for your points 1 and 2 above, could you link to a GitHub Gist or similar minimal working example which reproduces these issue(s)?

---

<div class="post-metadata">

**Author:** ![jbednar](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pangeo.io/jbednar/32/951_2.png) [@jbednar](https://discourse.pangeo.io/u/jbednar)\
**Post date:** [June 22, 2021, 7:52pm UTC](https://discourse.pangeo.io/t/xarray-and-panel-selecting-location-on-map/1564/4 "2021-06-22T19:52:09Z")

</div>

Sorry for the late reply; I’ve been at the beach!

1. I believe the controls normally do work when an hvplot is embedded in a panel, and it’s also possible to separate the controls from the plot if you need to lay them out separately. I’d have to see an example of what’s not working for you to see what to suggest.
2. You can use the `widgets` argument to pn.Param (see [Param — Panel 0.11.3 documentation](https://panel.holoviz.org/user_guide/Param.html#custom-widgets)) to specify a non-default widget, if you have one that you’d prefer to use instead of the default.
3. Yes! [examples.pyviz.org/landsat](http://examples.pyviz.org/landsat) shows how to do that with a Hover tool, and it’s similar with a Tap tool.

I’d be happy to help go over these with you via zoom, especially if you’d be happy to release the result as a public example…

---

<div class="post-metadata">

**Author:** ![khider](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pangeo.io/khider/32/613_2.png) [@khider](https://discourse.pangeo.io/u/khider)\
**Post date:** [June 23, 2021, 9:23pm UTC](https://discourse.pangeo.io/t/xarray-and-panel-selecting-location-on-map/1564/5 "2021-06-23T21:23:13Z")

</div>

Thanks, let me try to work with the info you sent. But a consult call will be more than welcome.

I can make the resulting notebook public. The only problem might be to move the data. It’s currently on our (publicly accessible) server but one would have to download the data to use it.

---

<div class="post-metadata">

**Author:** ![khider](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pangeo.io/khider/32/613_2.png) [@khider](https://discourse.pangeo.io/u/khider)\
**Post date:** [June 24, 2021, 6:08pm UTC](https://discourse.pangeo.io/t/xarray-and-panel-selecting-location-on-map/1564/6 "2021-06-24T18:08:28Z")

</div>

Example notebook with the problems here: [GitHub - khider/xarray-visualization: Notebooks illustrating xarray-based visualizations](https://github.com/khider/xarray-visualization).

---

<div class="post-metadata">

**Author:** ![jlstevens](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pangeo.io/jlstevens/32/1067_2.png) [@jlstevens](https://discourse.pangeo.io/u/jlstevens)\
**Post date:** [June 25, 2021, 1:26pm UTC](https://discourse.pangeo.io/t/xarray-and-panel-selecting-location-on-map/1564/7 "2021-06-25T13:26:51Z")

</div>

Thanks for the example notebook!

I’ll have a go reproducing the problems you have encountered (all the things described are reasonable and should work) and I’ll get back to you on Monday.

---

<div class="post-metadata">

**Author:** ![rsignell](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pangeo.io/rsignell/32/447_2.png) [@rsignell](https://discourse.pangeo.io/u/rsignell)\
**Post date:** [June 25, 2021, 3:33pm UTC](https://discourse.pangeo.io/t/xarray-and-panel-selecting-location-on-map/1564/8 "2021-06-25T15:33:05Z")

</div>

@khider, in case it’s useful we have a “[HRRR Explorer](https://bokeh-pangeo.usgs.gov/HRRR-Explorer)” panel app that has some similarity with the use case you describe.

The notebook that created that app is in this [reproducible notebooks repo](https://github.com/reproducible-notebooks/Holoviz-Demos).

Also see this simple [click-and-get-time-series example](https://discourse.holoviz.org/t/simple-panel-example-of-map-time-series-interaction-for-data-cube/1485/3).

---

<div class="post-metadata">

**Author:** ![jlstevens](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pangeo.io/jlstevens/32/1067_2.png) [@jlstevens](https://discourse.pangeo.io/u/jlstevens)\
**Post date:** [June 30, 2021, 1:42pm UTC](https://discourse.pangeo.io/t/xarray-and-panel-selecting-location-on-map/1564/9 "2021-06-30T13:42:56Z")

</div>

I have downloaded the example notebook and set up the environment. Based on the filename, I believe this is the dataset I need? [NASA IT Security Warning Banner](https://hydro1.gesdisc.eosdis.nasa.gov/data/GLDAS/GLDAS_NOAH025_M.2.0/1948/)

I just want to make sure before I set up an Earthdata account to download the necessary data…

---

<div class="post-metadata">

**Author:** ![khider](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pangeo.io/khider/32/613_2.png) [@khider](https://discourse.pangeo.io/u/khider)\
**Post date:** [June 30, 2021, 4:16pm UTC](https://discourse.pangeo.io/t/xarray-and-panel-selecting-location-on-map/1564/10 "2021-06-30T16:16:59Z")

</div>

Sorry I though I put the link in the notebook. The data on our server is public.

[Index of /files/raw-data/](https://data.mint.isi.edu/files/raw-data/) and contained in the folders GLDAS\_NOAH025\_M2.0 and GLDAS\_NOAH025\_M2.1

---

<div class="post-metadata">

**Author:** ![khider](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pangeo.io/khider/32/613_2.png) [@khider](https://discourse.pangeo.io/u/khider)\
**Post date:** [June 30, 2021, 4:17pm UTC](https://discourse.pangeo.io/t/xarray-and-panel-selecting-location-on-map/1564/11 "2021-06-30T16:17:57Z")

</div>

Thanks! I can definitely reuse some of it!

---

<div class="post-metadata">

**Author:** ![jlstevens](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pangeo.io/jlstevens/32/1067_2.png) [@jlstevens](https://discourse.pangeo.io/u/jlstevens)\
**Post date:** [July 9, 2021, 4:19pm UTC](https://discourse.pangeo.io/t/xarray-and-panel-selecting-location-on-map/1564/12 "2021-07-09T16:19:46Z")

</div>

Just to say I now have the notebook running and I’m working through the issues you’ve raised.

- Transparency slider is disables (Get an error when uncommenting surf\_plot.opts that column object don’t support opts)

This is because the use of `groupby='time'` means that `hvplot` no longer returns a HoloViews object and instead returns a panel column with widgets for controlling the groupby, making it tricky to apply `.opts` to the underlying HoloViews object.

Anyway, I’ve managed to fix this issues (including the variable change problem) with this approach for your first visualization:

```auto
class GliderParams(param.Parameterized):
    '''Class containing the method for the map'''
    
    dataset = param.Selector(dataset_option.keys(), default = 'GLDAS v2.1', 
            label = 'Dataset')
    surface_var = param.Selector(surface_var_map.keys(), default = 'Temperature', label = 'Surface Field')
    alpha_slider = param.Magnitude(label='Transparency')
    
def surf_vec(dataset,alpha_slider,surface_var): 
        if dataset == 'GLDAS v2.0':
            surf_plot = v20_sel[surface_var_map[surface_var]].hvplot(alpha=alpha_slider, groupby='time',widget_location = 'bottom',cmap=var_select_map[surface_var])
        elif dataset == 'GLDAS v2.1':
            surf_plot = v21_sel[surface_var_map[surface_var]].hvplot(alpha=alpha_slider, groupby='time',widget_location = 'bottom',cmap=var_select_map[surface_var])               
        return surf_plot
    
gp = GliderParams()
pn.Row(pn.Param(gp, name=''), pn.bind(surf_vec, dataset=gp.param.dataset,
                                      alpha_slider=gp.param.alpha_slider, 
                                      surface_var=gp.param.surface_var))

```

Hope that is helpful! I’ll continue working through the notebook and thinking about how to address the remaining issues.

---

<div class="post-metadata">

**Author:** ![jbednar](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pangeo.io/jbednar/32/951_2.png) [@jbednar](https://discourse.pangeo.io/u/jbednar)\
**Post date:** [July 13, 2021, 2:42am UTC](https://discourse.pangeo.io/t/xarray-and-panel-selecting-location-on-map/1564/13 "2021-07-13T02:42:57Z")

</div>

Thanks @jlstevens ; I’ve previously reported that as an issue on hvPlot: [Consistent return type from .hvplot() · Issue #532 · holoviz/hvplot · GitHub](https://github.com/holoviz/hvplot/issues/532).

You can also simplify the code a bit:

```auto
def surf_vec(dataset,alpha_slider,surface_var): 
        data = v20_sel if dataset == 'GLDAS v2.0' else v21_sel
        return data[surface_var_map[surface_var]].hvplot(alpha=alpha_slider, 
            groupby='time', widget_location = 'bottom',
            cmap=var_select_map[surface_var])               

```

---

<div class="post-metadata">

**Author:** ![khider](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pangeo.io/khider/32/613_2.png) [@khider](https://discourse.pangeo.io/u/khider)\
**Post date:** [July 13, 2021, 10:30pm UTC](https://discourse.pangeo.io/t/xarray-and-panel-selecting-location-on-map/1564/14 "2021-07-13T22:30:35Z")

</div>

Thank you both! Was able to get a little further in the panel today!

---

<div class="post-metadata">

**Author:** ![khider](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pangeo.io/khider/32/613_2.png) [@khider](https://discourse.pangeo.io/u/khider)\
**Post date:** [July 14, 2021, 8:35pm UTC](https://discourse.pangeo.io/t/xarray-and-panel-selecting-location-on-map/1564/15 "2021-07-14T20:35:10Z")

</div>

I’m also getting the following warning from:

```auto
result['precip'].hvplot(groupby='time',widget_location = 'bottom', ylim=[-60,90],coastline=True,crs=ccrs.PlateCarree(), projection=ccrs.PlateCarree(),features = ['borders'])    

```

WARNING:param.main: features option not found for image plot; similar options include: []

Is it linked to getting an image when using groupby?

---

<div class="post-metadata">

**Author:** ![maximlt](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pangeo.io/maximlt/32/1167_2.png) [@maximlt](https://discourse.pangeo.io/u/maximlt)\
**Post date:** [September 29, 2021, 9:48am UTC](https://discourse.pangeo.io/t/xarray-and-panel-selecting-location-on-map/1564/16 "2021-09-29T09:48:22Z")

</div>

Hi @khider ! I just wanted to check in with you and see if you managed to solve your issues here. Don’t hesitate to reach us, the Holoviz team, if need be 🙂

---

<div class="post-metadata">

**Author:** ![khider](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pangeo.io/khider/32/613_2.png) [@khider](https://discourse.pangeo.io/u/khider)\
**Post date:** [September 29, 2021, 9:54pm UTC](https://discourse.pangeo.io/t/xarray-and-panel-selecting-location-on-map/1564/17 "2021-09-29T21:54:36Z")

</div>

Thank you! Yes I got somewhere. The last problem is that we’re on a server so quite slow. But the tech part for prototyping is working. I need to polish it and then will release it publicly.

---

<div class="post-metadata">

**Author:** ![maximlt](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pangeo.io/maximlt/32/1167_2.png) [@maximlt](https://discourse.pangeo.io/u/maximlt)\
**Post date:** [September 30, 2021, 10:03am UTC](https://discourse.pangeo.io/t/xarray-and-panel-selecting-location-on-map/1564/18 "2021-09-30T10:03:45Z")

</div>

Ok cool glad to here you’ve managed to get it working!
