How to extract 3D buildings in python

[THAT’S A REPOST FROM Q&A] I did not realized that there was a 3d dedicated section on the forum

Hello !

I am very new to osm and I need to get 3d osm buildings to make some computations on a urban area base on its spatial characteristic. So I would like to import 3d data from osm and then render it with Mayavi. For now I managed to get nodes ways and relations but I have no idea how they can describe a 3d environment since nodes only have a lat and lon field but no height field is given either by nodes, ways or relation . I checked the wiki 3d buildings section that did not helped … I was expecting to get at least a “height” tag or a “building:level” and a “roof” tag but none of the building I got has it.

Here is the code I used :

from osmapi import OsmApi

Osm = OsmApi() 
osmap = Osm.Map(4.880710339197041, 52.37878033919704, 4.88160966080296, 52.37967966080296)

the ways I get look like this :

{‘type’: ‘way’,
‘data’: {‘id’: 266556870,
‘visible’: True,
‘version’: 1,
‘changeset’: 21133875,
‘timestamp’: datetime.datetime(2014, 3, 16, 11, 35, 18),
‘user’: ‘florisje_BAG’,
‘uid’: 1974371,
‘tag’: {‘building’: ‘yes’,
‘ref:bag’: ‘363100012239321’,
‘source’: ‘BAG’,
‘source:date’: ‘2014-02-11’,
‘start_date’: ‘1005’},
‘nd’: [2720904559,

the relations I get look like this

{‘type’: ‘relation’,
‘data’: {‘id’: 3579718,
‘visible’: True,
‘version’: 1,
‘changeset’: 21133875,
‘timestamp’: datetime.datetime(2014, 3, 16, 11, 35, 24),
‘user’: ‘florisje_BAG’,
‘uid’: 1974371,
‘tag’: {‘building’: ‘apartments’,
‘ref:bag’: ‘363100012169487’,
‘source’: ‘BAG’,
‘source:date’: ‘2014-02-11’,
‘start_date’: ‘1650’,
‘type’: ‘multipolygon’},
‘member’: [{‘type’: ‘way’, ‘ref’: 266556957, ‘role’: ‘outer’},
{‘type’: ‘way’, ‘ref’: 266556953, ‘role’: ‘inner’},
{‘type’: ‘way’, ‘ref’: 266556956, ‘role’: ‘inner’}]}}