Closed LaurentBerder closed 2 years ago
Hi @LaurentBerder, and thanks for raising this issue. I'm looking forward to taking a shot at implementing this new feature (and also related issues https://github.com/luukvdmeer/sfnetworks/issues/124 and https://github.com/luukvdmeer/sfnetworks/issues/179, maybe via a single API), but I need to focus on other projects until the end of this year. Maybe you can get inspiration from the existing code in to_spatial_smooth
.
Right, it's after I saw you #124 that I actually had the idea (I think they're complimentary). Hadn't noticed the #179, sorry for the request had already been made.
I'll take a look at the existing code and try to tweak it.
Thanks for raising this!
It is a heavily requested feature it seems, so we need to work on it! The reasons why this argument is right now present in e.g. to_spatial_simple()
but not in to_spatial_smooth()
is that to_spatial_simple()
is just a wrapper around igraph::simplify()
, which has the possibility to summarise attributes with the edge.attr.comb
, see here. Hence, we just rely on igraph to take care of this. However, to_spatial_smooth
is completely self-implemented because there is no igraph function doing the same (as far as I know). Therefore, we also need to find a way to implement the summarise_attributes functionality by ourselves (possibly based on how igraph is handling this?).
There are now multiple issues requesting the same feature. To keep the overview I will only leave #120 open and link to this issue from there.
Got it @luukvdmeer, thanks for the heads-up. Will be looking forward to trying it out!
Hi,
I am working with a large amount of Open Street Map data that I use with sfnetworks. But as the data is large, and the ways of OSM are very short, I end up with a ton of edges, all with some useful attributes.
To ease the process, I need to decrease the number of edges by combining some together. So I thought the
tospatial_smooth
morph would be appropriate, because it would still allow me to go through the network (usingst_network_paths
) as long as I only agregate edges that are inbetween intersections.The problem is that the merger destroys the useful attributes that I need to use after the simplification.
Here's a reproducible example:
Now, the idea would be to merge all the edges that are bounded by intersections together, resulting in this example with 5 edges: But if I do this with
to_spatial_smooth
, I lose the content of attributesspeed_kph
andhighway
:Describe the solution you'd like Ideally, we should be able (as it is the case for some other morphs such as
to_spatial_simple
) to specifysummarise_attributes
, which indicates what kind of agregation is needed for specific attributes. In the given example, I'd use it as follows:To get the average
speed_kph
, and the most common value ofhighway