You are not logged in.

#1 2020-09-08 11:35:03

LAK97
Member
Registered: 2020-09-08
Posts: 4

How to extract 3D buildings in python

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 ...

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,
    2720904680,
    2720904685,
    2720904720,
    2720904953,
    2720904557,
    2720904508,
    2720904505,
    2720904588,
    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'}]}}

Offline

#2 2020-09-08 13:03:30

alesarrett
Member
Registered: 2017-10-21
Posts: 29

Re: How to extract 3D buildings in python

I'm not an expert in 3D, but I can tell you that "3D" information comes in OSM as any other information: through tags.
For buildings (https://wiki.openstreetmap.org/wiki/Key:building) you can have an explicit height=* tag giving you the exact height of the building, or you can use the building:levels=* tag, to be used as a proxy of the height of the building.
You can also look at more information in the Simple 3D building wiki page: https://wiki.openstreetmap.org/wiki/Simple_3D_buildings
Ale

Offline

#3 2020-09-08 15:55:14

LAK97
Member
Registered: 2020-09-08
Posts: 4

Re: How to extract 3D buildings in python

Hey thank you for your answer !

Yeah so I was expecting a "height" tag or a building:levels=* tag and also a roof tag ( I have already checked the wiki doc) but after having filtered all the building I got from the OsmApi I noticed that those tag were missing as you can see on the way I give in my previous message for example.... I have seen a bunch of people online importing data directly with different applications with a GUI (blender, sketchup ect...) so I guess the information is not missing but I don't know how to collect it ...

Offline

#4 2020-09-08 16:16:01

LAK97
Member
Registered: 2020-09-08
Posts: 4

Re: How to extract 3D buildings in python

I have just seen that there was a dedicated section of the forum to 3D in osm I will repost my question there thank you for your help !

Offline

Board footer

Powered by FluxBB