I am looking to go from a multi million Pandas dataframe with lon, lat and 4 other numerical columns to a Datashaded image with ideally hover tool but definitely a base map. I managed to simply use the basic example from the Datashader quickstart page but am not able to add a base map to it. By the way I if it is possible to use datashade with hvplot with this ammount of data and a hover tool that would be ideal but so far I see it have reprojection isses and the hover tool does not work even with index, hover_cols, rasterize and other options permutations.
Here is a simple example where I create a Datashader image and then try to make an interactive hvplot with this example data.
import pandas as pd
import sqlite3
import datashader as ds
import colorcet
import hvplot.pandas
import geopandas
from holoviews.operation import apply_when
from holoviews.operation.datashader import rasterize
df_pq = pd.read_parquet('much_better.pq')
df_pq =df_pq.rename(columns={'HLAT': 'lat', 'HLON': 'lon'})
# Tried with GeoPandas but it takes impossibly long
# gdf = geopandas.GeoDataFrame(
# df_pq, geometry=geopandas.points_from_xy(df_pq.lon, df_pq.lat)
# )
# gdf.hvplot(rasterize=True, geo=True, tiles=True)
cvs = ds.Canvas(plot_width=850, plot_height=500)
agg = cvs.points(df_pq, 'lon', 'lat')
img = ds.tf.shade(agg, cmap=colorcet.fire, how='log')
img
points = df_pq.hvplot.points(
x='lon',
y='lat',
width=1200,
height=700,
coastline=True,
rasterize=True,
# datashade=True,
# hover=True,
# cmap='hot',
geo=True,
# tiles='OSM',
# hover_cols='all',
# hover_cols=['OBSVALUE','TSONDE','OBS_ERROR','FLAG'],
# use_index=False
)
apply_when(
points,
operation=rasterize,
predicate=lambda x: len(x) > 100
)