spatialpandas
spatialpandas copied to clipboard
Compatibility between spatialpandas.dask.DaskGeoDataFrame and HoloViews, GeoViews and hvplot?
Hi,
Apparently, there is no support for spatialpandas.dask.DaskGeoDataFrames in HoloViz plotting libraries other than datashader.
A simple example:
import holoviews as hv
hv.extension("bokeh")
# I have a single-row Parquet file I created using spatialpandas.
# It only contains one row and one column, called geometry, which contains a MultiLine object.
# I can easily read in as a spatialpandas.dask.DaskGeoDataFrame:
from spatialpandas.io import read_parquet_dask
df = read_parquet_dask("sample_spatialpandas_row.parquet")
# I now want to plot the multiline. For instance, with hvplot:
import hvplot.dask
df.hvplot()
# This raises an exception: Supplied data type DaskGeoDataFrame not understood
# And the same goes for instance for GeoViews:
import geoviews as gv
gv.Path(df)
# It does not recognizes it as a geodataframe-like element, raising:
# ValueError: kdims: list length must be between 2 and 2 (inclusive)
The above is just an example, obviously. You can find the sample parquet file I used here (needs to be unzipped).
Having this working would allow datashading dinamically and directly from Holo/GeoViews/HvPlot using holoviews.operation.datashader on larger than memory datasets, backed by spatialpandas.dask.DaskGeoDataFrame, which would be amazing.
What do you think?
Thanks for dropping in at the right time! You can try out the just-added DaskGeoDataFrame support in HoloViews using something like:
git clone [email protected]:holoviz/holoviews.git
cd holoviews
git checkout dask_spatialpandas
pip install --no-deps -e .
and then re-running your code. I haven't tested your code with this work-in-progress branch, so I don't know if it will work yet, but you can see what we are testing it with at https://github.com/pyviz-topics/examples/pull/130 .
Thanks @jbednar for reaching out!
Sure, I will try it this afternoon and will provide feeback :)
Ok so I just tried with the branch dask_spatialpandas in HoloViews, and now it seems to be at least accepted. The following line:
plot = gv.Path(df)
Does not raise an exception anymore; but the plot is not generated. If I just write in a single-line cell in Jupyter:
plot
It only outputs what I think it is the hv.Dataset info:
:Path [Longitude,Latitude]
But the chart is not generated.
Also, for hvplot the ValueError still remains.