question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

HexTiles does behave strangely when used with hv.Dataset

See original GitHub issue

I prepare a map using

tile_opts = dict(height=plot_height, xaxis=None, yaxis=None, show_grid=False,
                 sizing_mode="scale_both", responsive=True)
map_tiles = gts.CartoLight.opts(style=dict(alpha=1), plot=tile_opts)

Then I do a plot with lon lat given in mercator coors

points = (hv.HexTiles(data[["lon", "lat", "change"]], kdims=["lon", "lat"],
                     vdims=["value"])
          .options(active_tools=['wheel_zoom'],tools=[hover])
          .opts(colorbar=False, alpha=0.3, aggregator=np.mean, gridsize=250))

map_tiles * points

which works perfectly and plots the hexbins beautifully where they are located (Germany). However, as I am using a hv.Dataset (I want a dropdown with an additional key) like this

points_ds = gv.Dataset(data[["lon", "lat", "value", "date"]])
points = (points_ds.to(hv.HexTiles, kdims=["lon", "lat"], vdims=["value"])
          .options(active_tools=['wheel_zoom'], tools=[hover])
          .opts(colorbar=False, alpha=0.3, gridsize=250))

map_tiles * points

the results are pretty strange. The plot does not appear most of times and when I click through the dropdown it’s always on some other point in the map.

image

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:19 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
philippjfrcommented, Jan 15, 2020

Appears to have been fixed in #4182

0reactions
anderl80commented, Jul 18, 2019

No worries, thanks for the support and sorry for distracting from the main problem.

I was able do “isolate” (still sorry for the over-engineered example 😃) the problem more. Please try to execute the following.

# generate random data points for GitHub issue
import random
import datetime
import numpy as np
import pandas as pd

muc_coords = {"lat": 48.137154, "lon": 11.576124}

# generate data
def random_date(start, end):
    """Generate a random datetime between `start` and `end`"""
    return start + datetime.timedelta(
        # Get a random amount of seconds between `start` and `end`
        seconds=random.randint(0, int((end - start).total_seconds())),
    )
lon = [random.randint(0,100)/10000+muc_coords["lon"] for _ in range(0,1000)]
lat = [random.randint(0,100)/10000+muc_coords["lat"] for _ in range(0,1000)]
val = [random.randint(0,100) for _ in range(0,1000)]
date = [str(random_date(datetime.datetime(2019,1,1),datetime.datetime(2019,1,10)).date()) for _ in range(0,1000)]
data = pd.DataFrame(list(zip(lon, lat, val, date)), columns=['lon', 'lat', 'change', 'date'])

# [x] check that there's no day without data
data.date.value_counts().sort_index()

import geoviews as gv
gv.extension("bokeh")

hexs = (gv.HexTiles(data, kdims=["lon", "lat"],
                     vdims=["change", "date"])
          .options(active_tools=['wheel_zoom'],tools=["hover"])
          .opts(colorbar=False, alpha=0.3, aggregator=np.mean))
		  
# everything works fine
hexs

# now we try to add a dropdown menu
hexs_ds = gv.Dataset(data)

hexs = (hexs_ds.to(gv.HexTiles, kdims=["lon", "lat"], vdims=["change"])
          .options(active_tools=['wheel_zoom'], tools=["hover"])
          .opts(colorbar=False, alpha=0.3, aggregator=np.mean))
		  
# click through dropdown menu and find shifted data (zoom out)
hexs

# to double-check try points instead; everything works as expected
points = (hexs_ds.to(gv.Points, kdims=["lon", "lat"], vdims=["change"])
          .options(active_tools=['wheel_zoom'], tools=["hover"])
          .opts(colorbar=False))

No 1 gives me image

No 2 gives me (already zoomed out because the starting graph was empty) image

Exactly the same happens if I use holoviews only instead of geoviews.

Read more comments on GitHub >

github_iconTop Results From Across the Web

HexTiles — HoloViews v1.15.3
As a simple example we will generate 100,000 normally distributed points and plot them using HexTiles : np.random.seed(44) hex_tiles = hv.
Read more >
SoLID EC Design Weekly Meeting Minutes - Experimental Hall A
96, followup: JLab test indicates the yield is 3 times lower, see SDU Ye's report on 2017/04/20, not measured, used factory gain vs....
Read more >
[ganeti/ganeti_webmgr] 67ce1e5 fix merge conflicts (4944 ...
-If you want to use another database engine besides the default SQLite (not -recommended for production), then in settings edit the following lines...
Read more >
Version 2.1.0.0 - GT New Horizons - Miraheze
After the update the "one Ring" will give you over time a lot of perm warp. Better not wear this ring for a...
Read more >
Meetings VIII, IX, X, XI - Brookhaven National Laboratory
The average of X90 and X45 (equivalently. 0. I t - t. I. April 12th, 2002. RHXC Spin Collaboration meeting. Used data set...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found