Skip to content

Instantly share code, notes, and snippets.

@Zia-
Created July 31, 2016 16:37
Show Gist options
  • Save Zia-/b8d2241c85406d7250e205e1864f304a to your computer and use it in GitHub Desktop.
Save Zia-/b8d2241c85406d7250e205e1864f304a to your computer and use it in GitHub Desktop.
import os
from xml.dom import minidom
proj_dir = "/Users/zia/Documents/journals/My_WriteUp/Terrain_Routing_New/osm_data_downloaded/singaporeMalaysia/numberOfNodesPerRoad"
rel_file_path = "osm.osm";
abs_file_path = os.path.join(proj_dir, rel_file_path)
result_rel_file_path = "numberOfNodesPerRoad.csv"
result_abs_file_path = os.path.join(proj_dir, result_rel_file_path)
xmldoc = minidom.parse(abs_file_path)
way = xmldoc.getElementsByTagName("way")
f = open(result_abs_file_path, 'w')
for w in way:
nd = w.getElementsByTagName("nd")
f.write(str(len(nd)))
f.write("\n")
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment