Adding multiple 3d terrain with multi dem file

Hello everyone, I have a large dem file of the entire country.
I uploaded this file to Cesium Ion and received the output of the terrain files in the format of z/x/y.terrain.
Inside the folder was a json file, which I added the address of this file to the Cesium3DTileset component to create my 3D map.
Everything works very well.
But I have a problem.
I want to have the 3D environment of some areas in the country with a higher resolution.
In fact, I want to be able to increase the resolution of any area I want with a new dem file.
I have the high-quality dem file of those areas. Now I want to know if there is a way that after adding a global dem file and creating a 3D map, I can create a part of the map with a higher quality using a more desirable dem file?
I don’t know if I was able to explain what I meant. I tried to upload that dem file for a specific region separately to Cesium Ion and then merge the output folders with the dem folders for the entire country that I had previously exported. But this method did not work.
I tried to do this by creating multiple Cesium3DTileset components, but this method does not work due to performance degradation.
This method has another problem. I use CesiumTileMapServiceRasterOverlay to create map tile images and I gave this component to the original Cesium3DTileset that was for the entire country dem. So if I want to use a separate json file for a specific region that points to a higher quality dem, those images will no longer work for this new component.
Also, creating multiple Cesium3DTileset components seems to produce multiple spheres.

Solving this problem is very important for me and I would appreciate it if it is possible and if there is a way.:heart:

1 Like

Hi @amir_hamed,

The recommended way to approach this is to upload your more detailed DEM to Cesium ion as well, and select the original, lower-detail terrain as the “Base Terrain”.

Then, you can point a Cesium3DTileset as that newly-created asset, and it will have both the original lower-detail plus the high-res inset. Or you can point to the original asset and get just the lower-detail.

Sorry, I didn’t understand what you meant.
Are you saying that I should create 2 Cesium3DTileset components and also create a CesiumTileMapServiceRasterOverlay that affects both components?
I think I couldn’t express my problem correctly.
If I want to create 2 Cesium3DTileset components, it means that 2 globes will be created simultaneously.
One globe that contains my main elevation data includes the entire country and one globe containing elevation data related to a specific region that only has elevation data for that specific region and the rest of the globe areas have 0 elevation.
This method creates several problems:
1- Overlapping of 2 globes: This causes the elevations of the 2 globes to overlap and since the elevations change slightly at different zoom levels, it becomes very awkward and this overlap is very noticeable.
2- Severe performance degradation: As I said, it seems very illogical to create a separate sphere for each part of the map that I want a more accurate elevation file for that area, which only shows the elevation of that area. This both reduces performance drastically and I have to create a new sphere for each new area, which creates a terrible overlap.

There should be a way to, for example, place the folders output from the higher quality dem in the output folders related to the main dem, or there should be a separate component that, by giving the address of a json file, replaces the area at that address with the elevations in the main Cesium3DTileset.
I hope I was able to express my problem correctly.
And thanks for your answer :heart:

Another way.
Is it possible to modify the cesium3dTileset json file to use different addresses for specific geographic areas?

if I understand you correctly here is what you want to do

you have global base terrain (cesium world terrain).

you have country wide even higher resolution dem file.

and few areas like for example airport with highest resolution dem and imagery both.

you want all this to be displayed on globe and when you zoom to those specific area higher res takes the precedence.

2 approches.

online and offline

1 online

lets first handle dem files upload it to cesium ion and choose cesium world terrain as base terrain.

once porcess is finised remember the asset id and give name for next step. assuming newly created asset has name of india_cwt.

now you have high res insets of airports (just an asumption it could be anything) upload all to cesium ion and choose newly created asset as base terrain in our case india_cwt in terrain options.

BOOM :fire: you have 3 levels of terrain global base terrain, country wide hige res and few location with highest resolution.

lets assume we have given a name as “my_terrain“.

now from here you have two option for adding satalite imagery with high res. you can process them individually then download each and add json file url path in cesiumtmsrasteroverly component for each location which is bit tedious if you have too many location.

second option is to upload all high res imagey to all at once select appropriate option during the tiling and remember to select base terrain as “my_terrain“.

double boom :fire: :fire: you are done at this point you can simple create one cesium3dtileset and point it to asset id of last created asset.

if you want to do this entire workflow offline you have option to choose cesium ion self hosted.

Let me know if you find any step difficult to understand.

Hello @Aankit_K
Thanks for your answer.
You understood my problem correctly.
I uploaded the DEM file of the entire country to the site and saved it in the format of z/x/y.terrain folders, which was also a json file next to the zoom folders, which I give the address of this file to the Cesium3DTileset component in Unity so that I can have the 3D map offline.
Now, as you said, I uploaded the DEM files related to some regions of the country with higher resolution to the site and received the output as before.
Of course, I always selected the specified option in the section below.

Both for the main DEM file and for the file related to other DEMs. But now I want to do what you did.
That is, first I upload the DEM of the entire country and save it with the desired name.
Then I upload the DEM file of my desired region and definitely select the option related to the main DEM from the list.
That’s all I understand.
I want to know what exactly I should do next? Should I export the new dem file I uploaded as the original dem?
If I export again, it gives me the same z/x/y.terrain folders. By the way, I have two folders that contain z/x/y.terrain folders and I don’t know how to use the json file of both folders in the Cesium3dTileset component.
If I don’t export again, should I download the original dem file again after uploading the new dem file and just use that?
Sorry for asking so many questions and I would really appreciate it if you could help me further.

when you choose cesium world terrain as a base terrain in terrain option you don’t get a option to download it offline as far as I know. you can only stream tiles from cesium ion. you might have not followed the steps correctly I assume.

if you have multiple folder with z/x/y.terrain type there is no way you can merge them just by copy pasting if follows the quatized mesh spec internally which has child tiles information embedded in terrain file. if you really wants to mearge them then you have to upload both dem files at the same time and then download them then you can use that json url to load them in unity

As you showed in the picture, I first selected the Raster Terrain option from the What kind of data is this? section, and then selected the Mean Sea Level option in the Base Terrain section, and then exported the file in the format of z/x/y.terrain folders.
Do you know a way or do you know how to write a json file so that I can use multiple exported folders so that I can use the specified folders at different zooms.
Or another way.
I think it shouldn’t be that complicated.
What I want to do is a fairly routine and normal task where I want to have some areas with better resolution to create the appropriate quality for those areas at high zooms.
Several libraries that I used before had this possibility.
All my work is based on this point.
I spent several months on the project and used Cesium. It’s very good in all cases, but I can’t fix this problem.
Please if anyone has more information, please let me know.
Thank you again, my friend

you have to retile it I don’t see other option.

And you have to specifly cesium world terrain as base terrian in terrain option not mean sea level.

unlike typical gis software cesium for unity does not offer option to create multiple layers with varying resolution of dem data where higher res takes the precedence when camera is closer to the surface.

where each layer(terrain in our case) is stacked on top of previous if it is processed individually.

I understand and thank you for your answer.
I was just expecting Cesium to provide a feature where we could, for example, create a spherical map using a dem file for the United States and then, for example, have a 3D environment for the city of Chicago using a high-quality dem file for that area.

hey that can be done you have to use cesium cartographic polygon. I thought you have to merge terrain of individually processed geotiff like this Multiple terrain

kindly follow this I am 99% sure this is what you looking for

Clipping Tilesets – Cesium

1 Like

I solved my problem using Cesium Terrain Builder.

@amir_hamed would you mind sharing how?

Hello.

Yes, definitely.

But it takes some work and I need to write a script to do this automatically.

Well, I use the Cesium Terrain Builder library.
With this library, I give the address of my dem files folder and create a vrt file and then using that file I get the same output as Cesium Ion.
As z/x/y.terrain
The difference is that I do this offline and without any special restrictions.

And then with this library I create a json file for this output.
For example, I output the dem of the entire country with this and use this json in the Cesium3DTileset component.
Then, for example, I want to add the elevation data of the N12E33 region to my map or replace it with the previous elevation data with a better resolution.
So, I’m going to use the commands that the library gives me to export this dem file to the same path as the entire country’s dem output, and then I’ll export the json file and that’s it.
Of course, I’m currently updating the json file manually, which is not time-consuming for a few and continuous tiles, but if the files are discontinuous and many, it will take a while.
Of course, I need to be able to do a script for this that doesn’t require manual editing.
The library itself has put a more comprehensive explanation on github, and with a few simple searches, more information can be obtained.
I should also mention one thing that I encountered a challenge in this task, and that was that some parts of the globe were shown empty and no height data was created for it.
I asked the GBT chat and he told me that the zoom information from 0 to 4 in the json file is not correct, and I enter the following data in the available parameter for zooms from 0 to 4.

“available”: [[ { “startX”: 0, “startY”: 0, “endX”: 1, “endY”: 0 } ],[ { “startX”: 0, “startY”: 0, “endX”: 3, “endY”: 1 } ],[ { “startX”: 0, “startY”: 0, “endX”: 7, “endY”: 3 } ],[ { “startX”: 0, “startY”: 0, “endX”: 15, “endY”: 7 } ],[ { “startX”: 0, “startY”: 0, “endX”: 31, “endY”: 15 } ], …]

This approch will work only if high res tiles are continious assume If have high res tiles for california and new york it will not work it will output empty data for inbetween region and the way bounds are calculated from vrt is also a problem it will calculate every xyz tiles for inbetween tiles but for that we don’t have high res dem data. I have made a custom tool on top of CTB to automate this process but yet its not as good as cesium ion.

1 Like