holoviz / spatialpandas

Pandas extension arrays for spatial/geometric operations
BSD 2-Clause "Simplified" License
303 stars 24 forks source link

Compatibility between spatialpandas.dask.DaskGeoDataFrame and HoloViews, GeoViews and hvplot? #53

Open julioasotodv opened 3 years ago

julioasotodv commented 3 years ago

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?

jbednar commented 3 years ago

Thanks for dropping in at the right time! You can try out the just-added DaskGeoDataFrame support in HoloViews using something like:

git clone git@github.com: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 .

julioasotodv commented 3 years ago

Thanks @jbednar for reaching out!

Sure, I will try it this afternoon and will provide feeback :)

julioasotodv commented 3 years ago

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.