-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
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
Plotting capabilities #82
Comments
Thanks for opening this issue, @martinfleis, and sorry for my delayed response! I agree I think using geopandas plotting makes the most sense. When I was exploring/ trying out working with vector xarray datasets, I tried using Xarray plotting functions, and that's where I ran into it not accepting the dimension containing geometry arrays, but I don't see that kind of visualization being a main use-case of vector data cubes. If anything, maybe there could be a utility function that wraps the steps to create a parallel dimension and swap from the geometry dim for xarray plotting purposes? Working on this kind of thing is relatively new for me so I'd love to hear any thoughts on why that may or may not be a useful feature. If it would be helpful, it's definitely something I'd be interested in working on, though I probably won't have a ton of time to do so in the next ~ 1 month. |
Since you now have n dimensions, stuff like faceting could be useful. We'll need to make xarray;s plotting module a bit more resilient to unknown data types. |
Faceting with the vector cubes would be cool! I was imagining a function to create a dummy dim of |
Is there a way we can expand the functionality of Xarray's plot from the Xvec's side? Or would it need to be something like |
I guess it would need the latter, but...
I'm wondering if it would make sense to make xarray's plotting work with geometries directly. Xarray has already a couple of tests using Cartopy, and Cartopy can plot shapely geometries. Perhaps it wouldn't be hard / big maintenance burden to add a special case in Xarray? Maybe Xarray's plotting functions would then just work for basic plotting of geometries? Not sure as I'm not very familiar with the Xarray plotting code. One possible annoying thing is the different CRS objects used here vs. in Cartopy, something I guess you already have to deal with in geopandas. |
Plotting code for vector geometries is completely different beast than rasters as we need to create the whole maptlotlib object ourselves from patches, assigning colours to each... Knowing how this looks in geopandas I would recommend leaving that alone. |
I was more thinking about plotting via cartopy (i.e., add_geometries()) than re-implementing all of that with matplotlib... I'd totally follow your recommendation otherwise :-) ! |
Oh add_geometries is quite the plot twist! |
Perhaps HoloViz could serve as the default plotting library for xvec, so that xvec_ds.plot() -> xvec_ds.hvplot(). A basic demo of this is available in a hvPlot PR, where the data is converted to GeoPandas and plotted using hvPlot's existing support for GeoPandas. However, I believe there's potential for a more impactful implementation involving GeoViews. |
hvPlot is great and it would be nice if it could work seamlessly with xvec (i.e., your open hvplot PR) or vector data cubes in general! That said, using hvPlot (HoloViz) as a default plotting library here would be a pretty strong opinionated choice IMO. I know that Holoviz supports multiple backend libraries including matplotlib, but from my experience it seems to work best (and by default uses) Bokeh. Cartopy / Matplotlib seems a bit less opinionated for basic (static) plots to me. |
The easiest option is likely to use Matplotlib via GeoPandas. You will probably need to convert to a GeoDataFrame anyway. |
@e-marshall you have mentioned that plotting of vector data cubes is a bit cumbersome. I have to admit I never thought about including some plotting features as I assumed you just go via a GeoDataFrame and use its plot/explore methods but if you have ideas how we could improve plotting experience, I'm all ears.
Just two notes.
The text was updated successfully, but these errors were encountered: