Hey #spatial #R folks, is it possible to extract geometries from #ggplot as files? That is, the point, line, and polygon geometries in the graphs to #geopackage or #shapefile etc.

It is possible with #seaborn and #matplotlib, but that's Python not R. There's a nice and lightning fast #EdgeBundling technique in the newest ggplot, which is very promising for the #visualization of massive #mobility data.

There is also something in #HoloViews but I do not understand that library at all.

@waeiski you might start and see what luck you have with layer_data()
@waeiski ... which shows the underlying data for plotting a specified layer in the last plot. layer_date(i = 2) if the second layer is the one you are interested in.

@EvaMaeRey @defuneste Thank you for the inputs.

One would think this would be straight-forward, plotting anything requires the use of coordinates, no matter if they represent a value range, or geographical coordinates, so extracting the geometric shape should retain the coordinate information, which should be rather trivial to turn into a spatial file with a CRS.

@waeiski @EvaMaeRey @defuneste that's what layer_data does. For a layer added with geom_sf, you get the geometric features in `sf` format which you can write to any OGR format with `st_write`. Couldn't be much more straightforward unless I'm misunderstood your exact problem...
@geospacedman @waeiski @defuneste I've run into it defying my expectations with ggrepel, thinking I could extract the rendered positions, but that failed... thus a little hesitation. 🤞 for this case!