I have LoD1 building data from a federal agency in Germany in the CityGML
format. I would like to import and strip the data into R
to get only the footprint of the buildings and an attribut about the height. In case of building parts with different heights I would ideally get a the building footprint with multiple height fields (or a list containing the different height information). sf
let's me import the data but I only partially gives the expected result: While it works for some buildings, for other building only a part is imported. I included a sample from the data with one building where the import works just fine and the other where only parts of building are imported. I noticed that the structure of the cityObjectMember
from the first bldg:Building
is different and the gml:id
for this building is empty. Although I guess this is the reason why it's not imported correctly but I was wondering if this is because the data is corrupted or if there is a logic behind this.
I have no experience with CityGML but I also couldn't find tutorials on how to work with CityGML in R
or any other editor that would allow for anything beyon visualization.
How do I import and strip CityGML data in R?
Here's what I've tried so far:
library(dplyr)
library(sf)
#Import buildings
buildings = read_sf("test_building.xml")
# First building (with empty gml_id) not correctly imported
# Only spatial information for a part of the building is imported
plot(st_geometry(building[1,]))
#Second building (with gml_id==DENILD4300007ABe) works fine
plot(st_geometry(building[2,]))
sf
fails because there is no GMLAS driver included, c.f.sf::st_drivers()
.ogrinfo
andogr2ogr
with explicit GMLAS works just fine (c.f. here) on the other hand.