3D City Database
The 3D City Database is a free 3D geo database to store, represent, and manage virtual 3D city models. It is used by cities like Singapore, Berlin, Helsinki and many others.
The database schema implements the CityGML standard facilitating complex analysis tasks, far beyond visualization. It can be deployed on top of the relational database PostgreSQL with the GIS extension PostGIS installed.
Deployment
Start the 3D City Database with a Docker container by running this command:
docker run --name citydb -p 5432:5432 -d \
-e SRID=25832 \
-e SRS_NAME="urn:adv:crs:ETRS89_UTM32*DE_DHHN2016_NH" \
-e POSTGRES_DB=citydb \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=changeMe \
-e POSTGIS_SFCGAL=true \
3dcitydb/3dcitydb-pg
For further details checkout the documentation of the 3D City Database.
Importing Datasets
Import CityGML datasets into the database with the citydb-tool.
Therefore, replace <input_data_dir>
with your path to the directory containing your CityGML datasets as well as <citygml_files>
with the file names and run the following command:
docker run --rm --net=host --name citydb-tool \
-e CITYDB_HOST=localhost \
-e CITYDB_PORT=5432 \
-e CITYDB_NAME=citydb \
-e CITYDB_USERNAME=postgres \
-e CITYDB_PASSWORD=changeMe \
-v <input_data_dir>:/data \
3dcitydb/citydb-tool import citygml \
<citygml_files>
Geospatial Analytics
For example, list all road signs of type 283 sorted by distance to the POINT(678195.44 5403954.95 414.94)'::geometry)
:
SELECT
f.objectid AS objectid,
pn.val_string AS name,
ps.val_string AS subtype,
ST_3DDistance(g.geometry, 'SRID=25832;POINT(678195.44 5403954.95 414.94)'::geometry) as distance
FROM citydb.feature f
JOIN objectclass o ON f.objectclass_id = o.id
JOIN geometry_data g ON f.id = g.feature_id
LEFT JOIN (SELECT * FROM property WHERE property.name = 'name') AS pn ON f.id = pn.feature_id
LEFT JOIN (SELECT * FROM property WHERE property.name = 'opendrive_roadSignal_type') AS pt ON f.id = pt.feature_id
LEFT JOIN (SELECT * FROM property WHERE property.name = 'opendrive_roadSignal_subtype') AS ps ON f.id = ps.feature_id
WHERE o.classname = 'CityFurniture' AND pt.val_string = '283'
ORDER BY
ST_3DDistance(g.geometry, 'SRID=25832;POINT(678195.44 5403954.95 414.94)'::geometry)
This is the answer of the 3D City Database:
References
- GitHub repository of the 3D City Database
- Documentation of the 3D City Database
- Yao, Zhihang; Nagel, Claus; Kunde, Felix; Hudra, György; Willkomm, Philipp; Donaubauer, Andreas; Adolphi, Thomas; Kolbe, Thomas H.: 3DCityDB - a 3D geodatabase solution for the management, analysis, and visualization of semantic 3D city models based on CityGML. Open Geospatial Data, Software and Standards 3 (5), 2018, 1-26.