Skip to content

Add buildings to CityGML files

This tutorial shows how to create a simple solid building with SketchUp and export it to CityGML with the correct coordinates.

Note

This procedure also works with LoD2, with additional steps.

Setting up the SketchUp Template / Document

  1. Start SketchUp
  2. Go to File -> GeoLocation -> Add
  3. Select region as required and "grab" it.

Getting the coordinate origin for later georeferencing

  1. Find out the world coordinates of your SketchUp origin using GoogleMaps
  2. For this find the origin of your SketchUp coordinate system in GoogleMaps by comparing the images
  3. Place a marker at google maps (right click at desired location -> "what's here") which gives you the coordinates of this location in WGS84 Norting-Easting
  4. Copy and paste them in a text file for ease of use
  5. Go to: https://epsg.io/transform#s_srs=4326&t_srs=31467
  6. Convert your coordinates from WGS84 (Gmaps) to the desired one. Here we use "EPSG:31467 DHDN GK Zone3"
  7. Copy and paste the transformed coordinates in a text file for later use.

Modelling your buildings in SketchUp

  1. Save your current document, just in case we need to restart in the next step.
  2. Get the GEORES plugin and install it in SketchUp.
  3. Watch SketchUp tutorials on how to make simple buildings
  4. Once the buildings are made, select one at a time and click on the green house symbol from the GEORES Plugin Toolbar which says: "Erstelle ein neues Gebaeude"
  5. A pop-up appears, select "LoD1" or "LoD2" (depending on the roof shape) -> ok, a new pop-up appears, select "Solid" -> ok.
  6. Repeat this for all buildings.
  7. You can check that attributes of a building (e.g. gmlid) by going to the menu Tools -> GEORES citygml object dialog. Select an element and you can see the gmlid.

Exporting the SketchUp buildings to GML

  1. Go to menu Tools -> GEORES CityGML Export 2.0
  2. Fill in the values for Rechtswert, Hochwert with the ones we obtained before (in EPSG 31467)
  3. Fill in the height if you know it, else leave it empty. If you need this value depends on your application
  4. Select a path/file to store the GML.
  5. The other options don't seem to have an effect. Textures have not been tested.
  6. You must click on START now. If you close the dialog before clicking start it will not do anything!
  7. You will get a message that the file has been written successfully.

Repairing the exported GML

  1. There is a whitespace in one of the urls in the Tag which should not be there.
  2. Open the XML file with a text editor and look for this:
    <core:CityModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                    xsi:schemaLocation="http://www.opengis.net/citygml/2.0 ./CityGML_2.0/CityGML.xsd"
                    remove the whitespace here............................^
    
  3. Add the envelope behind the closing tag ">" of <core:CityModel..... > and before <core:cityObjectMember>. For example:
    <gml:boundedBy>
        <gml:Envelope srsName="EPSG:31467" srsDimension="3">
            <gml:lowerCorner>3513011.5993 5409874.8736 300</gml:lowerCorner>
            <gml:upperCorner>3513155.2613 5410004.6246 310.5</gml:upperCorner>
        </gml:Envelope>
    </gml:boundedBy>
    
  4. To obtain the coordinates of the envelope either add and subtract as many meters as you need or follow the same procedure as you did to get the coordinates of the SketchUp origin.
  5. The plugin exports .xml files, but SimStadt expects CityGML files to have .gml as extension. You can simply rename the extension from filename.xml to filename.gml.

Adding new buildings to an existing CityGML model

Assuming that both CityGML files have the same coordinate reference system, it is possible to copy-paste buildings from one CityGML file to another.

To do so, open both CityGML files in a text editor with syntax highlighting (e.g. NotePad++), and copy the corresponding buildings, starting at <core:cityObjectMember> and ending at </core:cityObjectMember>.

  • CityGML 1:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <core:CityModel ...>
      <core:cityObjectMember>
        <bldg:Building gml:id="A">
            ...
            ...
            ...
        </bldg:Building>
      </core:cityObjectMember>
      <core:cityObjectMember>
        <bldg:Building gml:id="B">
            ...
            ...
            ...
        </bldg:Building>
      </core:cityObjectMember>
    </core:CityModel>
    
  • CityGML 2:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <core:CityModel ...>
      <core:cityObjectMember>
        <bldg:Building gml:id="C">
            ...
            ...
            ...
        </bldg:Building>
      </core:cityObjectMember>
    </core:CityModel>
    
  • CityGML 1 + 2:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <core:CityModel ...>
      <core:cityObjectMember>
        <bldg:Building gml:id="A">
            ...
            ...
            ...
        </bldg:Building>
      </core:cityObjectMember>
      <core:cityObjectMember>
        <bldg:Building gml:id="B">
            ...
            ...
            ...
        </bldg:Building>
      </core:cityObjectMember>
      <core:cityObjectMember>
        <bldg:Building gml:id="C">
            ...
            ...
            ...
        </bldg:Building>
      </core:cityObjectMember>
    </core:CityModel>
    
cityObjectMember or Building?

In the video tutorial shown below, Buildings are copy-pasted around <bldg:Building>, which seems to work. It is advised to copy-paste <core:cityObjectMember>, though.