Created
April 26, 2016 06:52
-
-
Save Zia-/d3ad0c7b9be901bbe38817aa50aa8b86 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
from xml.dom import minidom | |
from osgeo import ogr | |
import os | |
from lxml.etree import tostring | |
# OSM data of Dar Es Salam can be downloaded from http://overpass.osm.rambler.ru/cgi/xapi_meta?*[bbox=39.0640,-7.1170,39.5269,-6.5767] | |
path_org = "<path to osm file>/planet.osm" | |
path_final = "<path to osm file>/planet_nodes.osm" | |
xmldoc = minidom.parse(path_org) | |
# Collecting lat, long, and name values of bus stations from OSM data | |
node = xmldoc.getElementsByTagName("node") | |
str = ''; | |
with open(path_final, 'w') as f: | |
f.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>") | |
f.write("<osm version=\"0.6\" generator=\"Overpass API\">") | |
f.write("<meta osm_base=\"2016-04-21T07:05:03Z\"/>") | |
for n in node: | |
lat = n.getAttribute("lat"); | |
lon = n.getAttribute("lon"); | |
# Following str lines could be merged into one | |
# Its only collecting nodes lat lon values | |
str = str + "<node lat=\'" | |
str = str + lat | |
str = str + "\' lon=\'" | |
str = str + lon | |
str = str + "\' />" | |
f.write(str); | |
f.write("</osm>") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment