2

I have got about 20000 small 3D models in form of .glb files.

Is there some way to project them onto heightmaps with GDAL or other software?

1
  • Welcome to GIS SE. As a new user, please take the Tour. We're a bit different than other forums, because we expect Questions to show an attempt to solve the task. Please Edit the Question to show what you have attempted, and report any problem(s) encountered.
    – Vince
    Aug 26, 2021 at 17:10

1 Answer 1

2

TL;DR

.glb -> blender -> .obj -> cloudcompare -> .gtif

Be carefull: this method does not handle coordinates.

More details :

There are several ways to do this, but unfortunately I don't know of one that directly turns a .glb file into a heightmap.

In my opinion, the simplest solution is to use the cloudcompare[1,2] software, which is initially designed to process lidar point clouds. CloudCompare can't read directly a .glb file, it is therefore necessary to transform the gld file into a file type readable by the software, like .obj (or .slt).

To turn the glb into an .obj I used blender. Just import the file, then save it as .obj. As you have many objects you can use the blender CLI to make the convertion (see here).

We can then load the obj file into cloudcompare, then transform it into a heightmap. For this 5 steps :

  1. In the "DB Tree" tab select the "vertices"
  2. Click on the "rasterisation" button
  3. On the rasterisation windows set the parameters
  4. Click on "update grid" for compute the grid
  5. Export the grid with the raster button

You can also make this steps with the CLI of cloudcompare (see here).

be carfull: this method does not handle coordinates. It will be necessary to reproject the raster.

Steps in cloud compare


1 You could do exactly the same thing using paraview or grass gis, but it is less easy to use.

2free softwares.

4
  • Thanks! I have two questions: 1. I have tried doing this with the CLI, but while there are no errors and it says it works, this command doesn't have an output: CloudCompare -O mesh.obj -RASTERIZE -GRID_STEP 1.0 -VERT_DIR 1 -PROJ MAX -EMPTY_FILL INTERP -OUTPUT_RASTER_Z How can I fix this? Is there some argument I also need to add? 2. Is it possible to also output it as a grayscale image, the image option gives me a RGB one. If no, what is the best way to convert the tif to something like png (when I open the raster with GIMP, it looks pretty different than with QGIS etc.)?
    – Til W.
    Aug 27, 2021 at 16:20
  • imgur.com/a/sWjtMkA * with the best option I mean one that is simple and possible with a CLI
    – Til W.
    Aug 27, 2021 at 16:28
  • 1
    You need to extract the vertices before the rasterisation. For exemple, for a "example.obj" file : 1. CloudCompare -O example.obj -EXTRACT_VERTICES 2. CloudCompare -O example.vertices.bin -RASTERIZE -GRID_STEP 1 -OUTPUT_RASTER_Z -EMPTY_FILL INTERP (the file "example.vertices.bin" is automaticaly created).
    – Atm
    Aug 27, 2021 at 17:03
  • 1
    The heigthmap (and more generaly the rasters) are data matrix (often altitude but not only) reprensented by images, not "true" images. Therefore the representation style is not fixed, evrey software use a specific color map, so the same fine can be represented deffenrently by two softwares. If you want to "fix" the representation I suppose that the geotiff must be transformed into a png or jpeg type image. This is something that seems to be possible with gdal, but I have never tried it.
    – Atm
    Aug 27, 2021 at 17:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.