pyrosm icon indicating copy to clipboard operation
pyrosm copied to clipboard

get_network(): Control number of rows in resulting edge dataframe

Open jscso opened this issue 3 years ago • 1 comments

Hi,

first of all: thanks for this very useful library. Really appreciate!

I do have a question regarding get_network() method. Could someone please give me a hint how the number of rows is controlled actually? Is there a way to define how many nodes are "merged" into a single row of the resulting edge dataframe?

I'm retrieving lots of rows even from the same way id and even when tags are very similar (or even identical). Is there a possibility to contract the result to the least amount of rows?

Thanks in advance!

jscso avatar Mar 29 '21 09:03 jscso

Hi @jscso! Good quesion 👍🏻

In case you are parsing the nodes and edges with nodes, edges = osm.get_network(nodes=True), then pyrosm will split all road segments between nodes which is needed for making the graph routable. Hence, there will be rows where all attributes are identical but only the geometry of the road segment differs. The plan is to add some cleaning steps in the future release, which reduces the number of duplicate rows.

In case you want to get the roads as they are represented in OSM (without any duplicate rows), you can get those by calling edges = osm.get_network(nodes=False). When using this approach, you unfortunately cannot create a routable graph out of the data. I hope this clarified things?

HTenkanen avatar Apr 21 '21 07:04 HTenkanen