luukvdmeer / sfnetworks

Tidy Geospatial Networks in R

Home Page:https://luukvdmeer.github.io/sfnetworks/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A slightly different approach for plot.sfnetwork

agila5 opened this issue · comments

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.

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

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