luukvdmeer / sfnetworks

Tidy Geospatial Networks in R
https://luukvdmeer.github.io/sfnetworks/
Other
333 stars 20 forks source link

A slightly different approach for plot.sfnetwork #226

Closed agila5 closed 1 year ago

agila5 commented 1 year ago

Is your feature request related to a problem? Please describe. I think that the current implementation of plot.sfnetwork is slightly inefficient when the input x contains spatially explicit edges (or draw_lines = TRUE). The problem is that, in those cases, dots$x mixes POINT and LINESTRING objects, which implies that do.call(plot, dots) actually calls sf:::plot.sfc_GEOMETRY. The function sf:::plot.sfc_GEOMETRY is less efficient than just calling sf:::plot.sfc_POINT and sf:::plot.sfc_LINESTRING separately since sf:::plot.sfc_GEOMETRY plots one node at a time whereas sf:::plot.sfc_POINT plots all points together.

Describe the solution you'd like Two separate calls to do.call to plot one set of features at a time. If you agree, I will prepare a PR.

Describe alternatives you've considered We can manually extract and plot nodes/lines, but that's quite boring.

loreabad6 commented 1 year ago

I totally agree, the plotting method is quite slow. Thank you @agila5 for preparing a PR.

luukvdmeer commented 1 year ago

Thanks @agila5, this is part of the new minor release. Much faster!