Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combine Terrain with CityGML #83

Open
ThomasPe opened this issue Dec 19, 2023 · 16 comments
Open

Combine Terrain with CityGML #83

ThomasPe opened this issue Dec 19, 2023 · 16 comments

Comments

@ThomasPe
Copy link
Contributor

hey, really love your tool!
Lately I was investigating on how to best combine terrain models (geotiff) with CityGML or CityJSON files. Since I'm new to Python I wanted to hear your thoughts on how to best approach this and perhaps contribute back to this codebase.

I tried combining seperately generated STLs (using cjio for the CityJSON model) afterwards with somewhat okayish results but that was a lot of work and error-prone.

I'm wondering if integrating the model generation into the TouchTerrain workflow would be the best approach (similar to how the GPX addition works), but I'm worried it might not be a simple as that as the addition of CityGML would potentially introduce holes to the model (thinking of bridges, for example).

The other approach would be to combine the STLs programatically later, however that would probably be also difficult to properly align all parts when the Geo-Data isn't there anymore.

Is there maybe something obivious I'm missing? Seems like there's a reason why not many tools (only found 1 tbh) can do this kind of merge already.

@ChHarding
Copy link
Owner

ChHarding commented Dec 19, 2023 via email

@ThomasPe
Copy link
Contributor Author

Thanks so much for your input!

I assume the issue is to have both the DEM and the building model need to have the same coordinate system and the mm-based STLs you get from TouchTerrain won’t work unless you manually scale and position your building model?

Exactly this. Source material (geotiff DEM & CityGML) both have the same coordinate system though.

use_geo_coords wasn't in the sample config json so I did miss that option, and it's looking promising.
When importing both files to 3D Builder they both also lie on top of each other. Only issue is that I can't get the terrain to scale properly yet, even with tilewidth_scale set to 1.0 the resulting . This is a partial of the config I'm using:

{
"basethick": 1,
"bllat": 48.0050717,
"bllon": 11.395237,
"fileformat": "STLb",
"importedDEM": "/workspaces/touchterrain/starnberg.tif",
"printres":-1,
"tilewidth_scale": 1.0,
"trlat": 48.0160216,
"trlon": 11.4154585,
"unprojected": false,
"use_geo_coords": "UTM",
"no_normals": false
}

@ChHarding
Copy link
Owner

ChHarding commented Dec 20, 2023 via email

@ThomasPe
Copy link
Contributor Author

I can post a sceenshot of how the models align in 3D Builder later tonight. When I don't pass any tileWidth it defaults to the 80m set in the code, so it seems tilewidth_scale is not doing anything right now in the STL export (at least when manually passing a DEM file).

@ChHarding
Copy link
Owner

ChHarding commented Dec 20, 2023 via email

@ChHarding
Copy link
Owner

ChHarding commented Dec 20, 2023 via email

@ThomasPe
Copy link
Contributor Author

Unfortunately GitHub censors all email addresses so I can't send the screenshots to you (I'm using GitHub in the browser).
I'll insert them here, hopefully you'll get them in the email as well. Otherwise I'll add a link to them.

Here's the full config file I used for this:

{
"CPU_cores_to_use": 0,
"DEM_name": "USGS/3DEP/10m",
"basethick": 0,
"bllat": 48.0050717,
"bllon": 11.395237,
"bottom_image": null,
"fileformat": "STLb",
"ignore_leq": null,
"importedDEM": "/workspaces/touchterrain/starnberg.tif",
"importedGPX": null,
"lower_leq": null,
"max_cells_for_memory_only": 1000000,
"no_bottom": false,
"ntilesx": 1,
"ntilesy": 1,
"only": null,
"printres":-1,
"smooth_borders": true,
"tile_centered": false,
"tilewidth": 80, // default, can't be null
"tilewidth_scale": 1.0,
"trlat": 48.0160216,
"trlon": 11.4154585,
"unprojected": false,
"zip_file_name": "terrain",
"zscale": 1.0,
"use_geo_coords": "UTM",
"no_normals": false
}

As you can see by the coordinates both models get projected into the right "area of the world" so to say, considering the big x & y values. However as can be seen by the second screenshot the terrain tile is exactly 80m (I imported as m instead of mm).

image

image

It should by somewhere around 1428m on the longer side (manally calculated). If I put that as tilewidth I get the following result. It looks good in terms of scaling but still is a bit off. Not sure if there are some discrepancies in how touchterrain and cjio (for the city model) translate coordinate systems, I'm looking into what cjio does currently.
image

For reference here's what it should look like (aligned roughly manually)
image

@ThomasPe
Copy link
Contributor Author

please disregard my last comment, the touchterrain output wasn't actually UTM as the standalone python script doesn't pass that argument (neither the tilewidth_scale). I'm fixing it locally and can perhaps PR that later.

Seems like 3D Builder only honors the coorinates of the first imported model and then aligns the second close by, so the screenshots are basically meaningless. :D

@ChHarding
Copy link
Owner

ChHarding commented Dec 21, 2023 via email

@ThomasPe
Copy link
Contributor Author

I opened a PR illustrating the issue I had.
#84

I'll try to get some demo files that are obivous in terms of positioning

@ChHarding
Copy link
Owner

ChHarding commented Dec 22, 2023 via email

@ThomasPe
Copy link
Contributor Author

absolutely, I removed the changes for now from TouchTerrrainEartheEngine.

@ChHarding
Copy link
Owner

ChHarding commented Dec 23, 2023 via email

@ThomasPe
Copy link
Contributor Author

Devcontainers do work with GitHub codespaces afaik but are mostly used with VS Code, yes.
It basically juist runs a docker image and mounts your repository so even though I'm on Windows I can run & debug the touchterrain code without having to set up any dependencies myself.

@ChHarding
Copy link
Owner

ChHarding commented Dec 23, 2023 via email

@ThomasPe
Copy link
Contributor Author

I think the Microsoft Dev Container extensions and Docker for Windows using WSL should suffice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants