gdal icon indicating copy to clipboard operation
gdal copied to clipboard

Missing geometries from CityGML files

Open MalteEBA opened this issue 5 years ago • 3 comments

Describe the bug If I load xml files out of this zip file (see below) in QGIS, the buildings aren't displayed correct. There are a lot of buldings missing or corrupt. I know, that this file contains all informations, cause with other programms (FME) I can extract them. I am not the only one, who has problems with xml files. see also: https://github.com/qgis/QGIS/issues/33222

How to Reproduce https://fbinter.stadt-berlin.de/fb/berlin/service_intern.jsp?id=a_lod1@senstadt&type=FEED http://fbarc.stadt-berlin.de/FIS_Broker_Atom/lod1/LoD1.zip

QGIS and OS versions 3.10 and 3.4.5-Madeira

Exemplary I toke 391_5820 and 5821 + 390_5820 and 5821 -these are displayed in red. In turquoise u can see the informations, which should be displayed. 2019-12-04 10_18_01-_Unbenanntes Projekt - QGIS

MalteEBA avatar Dec 04 '19 10:12 MalteEBA

Could you make a test. GMLAS driver finds 976 buildings from file lod1_391_5820.xml. How many buildings does FME find?

ogrinfo GMLAS:lod1_391_5820.xml -oo remove_unused_fields=yes -oo remove_unused_layers=yes building -so
INFO: Open of `GMLAS:lod1_391_5820.xml'
      using driver `GMLAS' successful.

Layer name: building
Geometry (lod1solid): PolyhedralSurface
Geometry (lod1terrainintersection): Multi Curve
Feature Count: 976
Extent (lod1solid): (391005.329000, 5820001.883000) - (392036.155000, 5821047.638000)
SRS WKT (lod1solid):
(unknown)
SRS WKT (lod1terrainintersection):
(unknown)
Geometry Column 1 = lod1solid
Geometry Column 2 = lod1terrainintersection
ogr_pkid: String (0.0) NOT NULL
id: String (0.0)
creationdate: Date (0.0)
function: String (0.0)
measuredheight_uom: String (0.0)
measuredheight: Real (0.0)
storeysaboveground: Integer (0.0)

EDIT: GDAL finds geometry for 488 buildings with

ogrinfo GMLAS:lod1_391_5820.xml -oo remove_unused_fields=yes -oo remove_unused_layers=yes building -sql "select * from building where lod1solid is not null"

jratike80 avatar Dec 04 '19 15:12 jratike80

Hey folks,

I was wondering, why this issue is opened fo so long, since I still cannot find good manuals/tutorials for GDAL-based transformation from CityGML. I checked the files from the download link of the OP. And tried a bit, since I have similar problems regarding another German CityGML-Dataset.

The ogrinfo-scripts of @jratike80 made it possible for me to check the files mor ein detail. The building geometries can be found in two main layers: 1.) building, 2.) consistsofbuildingpart.

ogrinfo GMLAS:"LoD1_391_5820.xml" -oo REMOVE_UNUSED_LAYERS=YES -al -so In addition, the point layer address1 is of multipoint geometry.

After this, I set up two transformations from CityGML to ESRI Shapefile Format:

ogr2ogr -f "ESRI Shapefile" "LoD1_391_5820-4.shp" GMLAS:"LoD1_391_5820.xml" -oo remove_unused_layers=yes -sql "select * from building where lod1solid is not null" ogr2ogr -f "ESRI Shapefile" "LoD1_391_5820-8.shp" GMLAS:"LoD1_391_5820.xml" -oo remove_unused_layers=yes -sql "select * from consistsofbuildingpart where buildingpart_lod1solid is not null" (You can see from the numbering of the target file that it was some trial and error to get the output I wanted :) )

So, FKZViewer shows the CityGML data as follows: image

And the two shapefiles in QGIS look like this: image

It seems to me that every (part of a) building is part of one of the shapefile layers in QGIS.

However, I would like to adress the following questions/open checks:

  • is the geometry data in the shapefiles valid with regards to simpe feature rules etc. (ogr2ogr documentation point out that

Some forced geometry conversions may result in invalid geometries, for example when forcing conversion of multi-part multipolygons with -nlt POLYGON, the resulting polygon will break the Simple Features rules.

)

  • is there an elegant way/sql-syntax to directly transform both layers (building and consistsofbuildinpart) at once?
  • usually there is non-geometry related data available in the CityGML file, which (at least to my understanding) gets lost by only selecting on the basis of the "solid is not null" statement. Does anyone can give a good example how to add these attributes (e.g. building function) to the geometries in the shapefile (so that they can be seen/worked with in the attribute table)?

cheers André

AndreM84 avatar May 05 '21 21:05 AndreM84

is there an elegant way/sql-syntax to directly transform both layers (building and consistsofbuildinpart) at once?

This seems to work:

-sql "SELECT lod1solid AS geom, measuredheight FROM building UNION ALL SELECT buildingpart_lod1solid AS geom, buildingpart_measuredheight as measuredheight FROM consistsofbuildingpart"

But at least with the files I am fighting with, the result (of course...) has 6+ geometries per building as all surfaces are included. This means floor, walls and roof. I am not sure how to prevent that as they are not necessarily modeled semantically, in my data they are just

      <bldg:lod1Solid>
        <gml:Solid>
          <gml:exterior>
            <gml:CompositeSurface>
              <gml:surfaceMember>
              <gml:surfaceMember>
              ...

kannes avatar Jul 31 '22 11:07 kannes