UrbanAnalyst / dodgr

Distances on Directed Graphs in R
https://urbananalyst.github.io/dodgr/
127 stars 16 forks source link

from-to-flows aggregation by sequence ? #195

Closed sriramab closed 1 year ago

sriramab commented 1 year ago

Hi,

If I have a list of (long,lat) of from and (long,lat) of to and a flow matrix, then does the flow matrix has to have exact sequence of points on x and y axis of the matrix as the sequence of from or to list? I am not clear on how the flow matrix origins and destinations are linked to thefrom and to points. Is it just by sequence or does sequence run through the matrix, column by column or does the sequence go row by row? I looked at the sample on the home page of the package, but as the flows and selected vertices are randomly chosen, the aggregate function is a little difficult to follow.

I have a flow matrix, where origin and destination, or in R terms, the row names and the column names of the matrix are string (city names) and I have a list of from and to points that are also city names and I have made a table of from points using the cbind example shown on the homepage with their coordinates. As the flow matrix does not have any coordinates, I am unsure how they are both connected in the aggregate function.

Thank you.

mpadge commented 1 year ago

Hi again @sriramab. Did you see the flows vignette? That has a bit more detail, and attempts to show that the flows matrix must be [num_from, num_to], so that the flowmat[i, j] is the strength of flow from i to j. But i see that the flow vignette isn't mentioned or linked from the main page. Feel free to add that as a PR if you like, and also to clarify the vignette a bit better if you like - I admit that's probably not as clear as it could be. I think some extra explanation at the end of the first section ("1. Flow Aggregation") would help to clarify confusion, so feel free to add there too if you want. Let me know, thanks!

sriramab commented 1 year ago

Yes, I did have a look at it, I will re-read again to see if I miss something. I was also wondering why the flow values are in float for my case. I am using interger flows between pairs of points and I do not understand the (aggregate) flow resulting in a float number on each segment/link.

mpadge commented 1 year ago

The floating point values are from the norm_sums parameter which defaults to TRUE. If you read ?dodgr_flows_aggregate, it includes an explanation of how a unit flow between two points can give aggregated flows of 0.5 and not 1.