OpenStreetMap buildings

From FlightGear wiki
Jump to navigation Jump to search
Autogen Scenery
Started in 11/2013
Description Improved autogen support for FlightGear using OSM data
Contributor(s) radi, vanosten, Soitanen, portreekid
Status Under active development as of 02/2016
Topic branches:

OSM generated buildings and roads.
Houses with gable roofs.

Buildings can be mapped in OpenStreetMap. Their shapes can be turned into 3D models for use in FlightGear scenery.


  • There are "just" 64 million buildings in OSM[1], most cities in the world have no buildings at all or just a few.
  • Only 1.04% of the buildings in OSM have a height specified. Ca. 1.4% has a known number of floors (levels).[2]
  • FlightGear cannot handle thousands of models in a view. Grouping models into bigger files improves performance to a very usable level, but is less practical unless automated.


A perl script ( is being written to turn the OSM data into 3D models. It is available at;a=summary. is another project, under active development as of 06/2014.

Note for Windows

  • Windows does not contain perl by default. You're advised to install Strawberry Perl for Windows. It is a simple installer; no need to dig into your system.
  • Cygwin is also advised, so "grep" can be used to get a list of building ids easily.
  • When working with shapefiles not coming from OSM you will need ogr2ogr, which is included in FWTools.

From OpenStreetMap

A single building

  1. Find the building in OpenStreetMap.
  2. Enable the "Data" overlay.
  3. Choose a manual area and drag a box around your building.
  4. Click your building, the way id will be shown. Copy this id.
  5. Run the following code, replacing 44338398 with your building's id:
perl -w 44338398
Next to this basic code, there are several options, to be added behind the basic code.
  • Lat/lon location of the model's origin:
-lat 52.00141 -lon 4.36966
  • Object name (not the .ac name!):
-n "Empire State Building"
  • Building height (in meters):
-h 15
Note: buildings are always sunk 5 m into the ground, in order to account for non-flat terrain. These 5 meters are added on top of (or below, if you like) the building height.
  • Create a xml file with a standard range animation:
  • Clean the shape by removing nodes that lie within a certain distance from the line that connects its two adjacent nodes. This results in much smaller files and allows more buildings to have a gable roof:

All buildings in an area

Lower Manhattan at dawn.
  1. Download a file with all data from the area, by visiting the following link and save it somewhere on your computer. This will only include buildings (building=yes) within the specified bounding box.[bbox=left,bottom,right,top][building=*][@meta]
    For example:[bbox=-74.02037,40.69704,-73.96922,40.73971][building=*][@meta]
  2. Get a list of wayids via grep "<way" map.osm|cut -f2 -d\">wayids.txt change the number after f where appropriate
    or sed -n 's|<way.*id="\(.*\)" .*>|\1|p' "map.osm" > wayids.txt
  3. For Windows users: Run for /f %a in (wayids.txt) do perl -w %a -f map.osm
    For others: Iterate through wayids.txt and assign each way id to $object and run perl -w $object -f map.osm on all the ids.

while ($wayid =<STDIN>) {
    system("./ -v -w $wayid ");

From another source

  1. Run ogr2ogr with:
    ogr2ogr -t_srs WGS84 -s_srs "ESRI::in_shp.prj" "out_shp.shp" "in_shp.shp"
  2. Run shp2osm with:
    perl "out_shp.shp" > "map.osm"
  3. Get a list of wayids via grep "<way" map.osm|cut -f2 -d\">file.txt
  4. Run perl -w $object -f map.osm on all the ids.

Related content

External links

  1. "OpenStreetMap Wiki". Retrieved 15 September 2012.
  2. building | Keys | OpenStreetMap Taginfo. Retrieved 15 September 2012.