We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
groupby
If there is only one unique category, datashader raises and shows a blank map:
File "/Users/ahuang/miniconda3/envs/hvplot/lib/python3.10/site-packages/holoviews/util/__init__.py", line 1013, in _process return self.p.operation.process_element(element, key, **kwargs) File "/Users/ahuang/miniconda3/envs/hvplot/lib/python3.10/site-packages/holoviews/core/operation.py", line 194, in process_element return self._apply(element, key) File "/Users/ahuang/miniconda3/envs/hvplot/lib/python3.10/site-packages/holoviews/core/operation.py", line 141, in _apply ret = self._process(element, key) File "/Users/ahuang/miniconda3/envs/hvplot/lib/python3.10/site-packages/holoviews/operation/datashader.py", line 1543, in _process shaded = shade._process(self, agg, key) File "/Users/ahuang/miniconda3/envs/hvplot/lib/python3.10/site-packages/holoviews/operation/datashader.py", line 1354, in _process img = tf.shade(array, **shade_opts) File "/Users/ahuang/miniconda3/envs/hvplot/lib/python3.10/site-packages/datashader/transfer_functions/__init__.py", line 717, in shade raise ValueError("agg must use 2D or 3D coordinates") ValueError: agg must use 2D or 3D coordinates
This is not ideal for groupby because it shows a blank map instead of just showing the single category.
To reproduce: Data download: https://coast.noaa.gov/htdata/CMSP/AISDataHandler/2020/index.html
import pandas as pd import hvplot.pandas import geoviews as gv import pandas as pd import datashader as ds import colorcet as cc import holoviews as hv import holoviews.operation.datashader as hd from holoviews.util.transform import lon_lat_to_easting_northing df = pd.read_csv("AIS_2020_01_01.csv", parse_dates=True, index_col="BaseDateTime") df = df.assign( **pd.concat(lon_lat_to_easting_northing(df["LON"], df["LAT"]), axis=1).rename( {"LON": "EASTING", "LAT": "NORTHING"}, axis=1 ) ) df.index = df.index.round("1Min") df = df.sort_index() df.index = df.index.astype(str) vessel_types = pd.read_csv("AIS_categories.csv") categories = { r.num: r.category if r.category in [0, 2, 3, 6, 7, 16, 14, 19, 12, 18] else 21 for i, r in vessel_types.iterrows() } def category_desc(val): """Return description for the category with the indicated integer value""" return vessel_types[vessel_types.category == val].iloc[0].category_desc groups = {categories[i]: category_desc(categories[i]) for i in categories.keys()} colors = cc.glasbey_bw_minc_20_minl_30 color_key = { list(groups.keys())[i]: tuple(int(e * 255.0) for e in v) for i, v in enumerate(colors[: (len(groups))][::-1]) } legend = hv.NdOverlay( { groups[k]: hv.Points([0, 0], label=str(groups[k])).opts( color=cc.rgb_to_hex(*v), size=0 ) for k, v in color_key.items() } ) df = df.loc[df["VesselType"].isin(color_key)] pts = hv.Dataset(df, kdims=["EASTING", "NORTHING"], vdims=["VesselType"]).to( hv.Points, groupby=["BaseDateTime"] ) points = hd.dynspread( hd.datashade(pts, aggregator=ds.count_cat("VesselType"), color_key=color_key) ) tiles = ( hv.element.tiles.ESRI() .opts(alpha=0.4, bgcolor="black") .opts(responsive=True, min_height=600) ) labels = hv.element.tiles.CartoDark().opts(alpha=0.7, level="glyph") display( tiles * labels * points.opts(show_legend=False) * legend.opts(xaxis="bare", yaxis="bare", title="") )
Works fine when it's not on the one category time
The text was updated successfully, but these errors were encountered:
No branches or pull requests
If there is only one unique category, datashader raises and shows a blank map:
This is not ideal for
groupby
because it shows a blank map instead of just showing the single category.To reproduce:
Data download: https://coast.noaa.gov/htdata/CMSP/AISDataHandler/2020/index.html
Works fine when it's not on the one category time
The text was updated successfully, but these errors were encountered: