OpenStreetMap buildings: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
(Gable roofs image)
(Shapefiles not coming from osm can be used as well!)
Line 9: Line 9:


=== Note for Windows ===
=== Note for Windows ===
Windows does not contain perl by default. You're advised to install [http://strawberryperl.com/ Strawberry Perl for Windows]. It is a simple installer; no need to dig into your system.
* Windows does not contain perl by default. You're advised to install [http://strawberryperl.com/ Strawberry Perl for Windows]. It is a simple installer; no need to dig into your system.
* [http://www.cygwin.com/ 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 [http://fwtools.maptools.org/ FWTools].


[http://www.cygwin.com/ Cygwin] is also advised, so "grep" can be used to get a list of building ids easily.
== From OpenStreetMap ==
 
=== A single building ===
== A single building ==
# Find the building in OpenStreetMap.
# Find the building in OpenStreetMap.
# Enable the "Data" overlay.
# Enable the "Data" overlay.
Line 28: Line 29:
::* '''Building height''' (in meters):
::* '''Building height''' (in meters):
:::: <code>-h 15</code>
:::: <code>-h 15</code>
:::: '''Note:''' buildings are always sunk 5 m into the ground, in order to account for non-flat terrain.
:::: '''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:
::* '''Create a xml file''' with a standard range animation:
:::: <code>-x</code>
:::: <code>-x</code>


== All buildings in an area ==
=== All buildings in an area ===
[[File:New York with OSM buildings dawn.png|thumb|270px|Lower Manhattan at dawn.]]
[[File:New York with OSM buildings dawn.png|thumb|270px|Lower Manhattan at dawn.]]
# 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.
# 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.
#: <code><nowiki>http://overpass-api.de/api/xapi?way[bbox=left,bottom,right,top][building=*][@meta]</nowiki></code>
#: <code><nowiki>http://overpass-api.de/api/xapi?way[bbox=left,bottom,right,top][building=*][@meta]</nowiki></code>
#: <code><nowiki>http://overpass-api.de/api/xapi?way[bbox=-74.02037,40.69704,-73.96922,40.73971][building=*][@meta]</nowiki></code>
#: <code><nowiki>http://overpass-api.de/api/xapi?way[bbox=-74.02037,40.69704,-73.96922,40.73971][building=*][@meta]</nowiki></code>
# Get a list of wayids via <code>grep "<way" map.osm|cut -f2 -d\">file.txt</code>
# Run <code>perl bob.pl -w $object -f map.osm</code> on all the ids.
== From another source ==
# Run ogr2ogr with:
#: <code><nowiki>ogr2ogr -t_srs WGS84 -s_srs "ESRI::in_shp.prj" "out_shp.shp" "in_shp.shp"</nowiki></code>
# Run [http://wiki.openstreetmap.org/wiki/Shp2osm shp2osm] with:
#: <code><nowiki>shp2osm.pl "out_shp.shp" > "map.osm"</nowiki></code>
# Get a list of wayids via <code>grep "<way" map.osm|cut -f2 -d\">file.txt</code>
# Get a list of wayids via <code>grep "<way" map.osm|cut -f2 -d\">file.txt</code>
# Run <code>perl bob.pl -w $object -f map.osm</code> on all the ids.
# Run <code>perl bob.pl -w $object -f map.osm</code> on all the ids.

Revision as of 11:25, 10 April 2012

WIP.png Work in progress
This article or section will be worked on in the upcoming hours or days.
See history for the latest developments.
OSM generated buildings and roads.
Houses with gamble roofs.

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

Tools

A perl script is being written to turn the OSM data into 3D models. It is available at https://gitorious.org/fgscenery/tools.

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 bob.pl -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:
-x

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.
    http://overpass-api.de/api/xapi?way[bbox=left,bottom,right,top][building=*][@meta]
    http://overpass-api.de/api/xapi?way[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\">file.txt
  3. Run perl bob.pl -w $object -f map.osm on all the ids.

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:
    shp2osm.pl "out_shp.shp" > "map.osm"
  3. Get a list of wayids via grep "<way" map.osm|cut -f2 -d\">file.txt
  4. Run perl bob.pl -w $object -f map.osm on all the ids.

External links