Hi, I have an OSM city map which I export in OSM XML data format and feed into a mobility simulator that pulls the road network out of the map. I now need however to parse the OSM map to get the coordinates of obstacles (buildings only considered)in the map, hopefully in CSV format as I need to import these into a network simulator. Could someone please let me know if such an xml parser exists to get the coordinates of the buildings or if not could the structure of the tags please be explained so that I can write a parser. Many thanks in advance. asked 29 Dec '12, 13:24 kerrymaid |
The easiest would be to write it yourself. There are lots of libraries available for all kind of languages that read XML. The thing you want is quite specific, so there's no ready-made tool available. The XML in OSM has three primitives: nodes, ways and relations. A node is just a pair of lat/lon coordinates. A way is an ordered list of nodes, and a relation is an ordered list of other types (nodes, ways and other relations). All these features have an id (in the xml denoted with the "id" attribute), these ids are used as reference (so the XML structure of an OSM way is just a list of node ids). All primitives also have tags, these are stored as separate child XML elements of the type "tag". So if you're interested in the buildings, you have to filter out all the ways (ways with the same start and end point are also used for surfaces) with a tag building=*, then get the nodes from those ways (via the id) and from those nodes, extract the coordinates (I don't know if you want one average coordinate per building, or if you want all nodes that represent building corners, but you can program both as you wish). answered 30 Dec '12, 11:16 Sanderd17 1
... so your starting point to find some tools can be the OSM wiki about http://wiki.openstreetmap.org/wiki/Develop
(31 Dec '12, 07:49)
stephan75
|