# Building a program to convert LiDAR data directly to an STL or directly to G-code

Some people have figured out how to take raw LiDAR data and after going through multiple steps (using LAS tools, converting to digital elevation model (DEM), converting to an STL) getting an STL file that they can then slice and print.

Could you write a program that cuts out all of those intermediate steps and converts raw LiDAR data directly to an STL that can be printed? Could you even cut out the need for slicers and just go straight to a G-code file?

Is this even possible?

1. Retrieve Lidar Data
2. Process Lidar Data
3. Create a DSM
4. Export the DSM into a .STL
5. Process for 3D Printing
6. 3D Print!
• Thanks for accepting my answer - it was mostly supposition really. Hi and welcome to SE.3DP, BTW. Don't forget to take the tour - you'll earn another badge to add to your rapidly growing collection. :-) Jul 13 '21 at 15:28
• @Greenonline your answer was great. Your answer had to be supposition because my question was too. You've got me thinking and doing extra research, so of course it was a great answer. Jul 13 '21 at 16:55

TL;DR - The problem would appear to be that some of the steps require a bit of manual tinkering in order to complete them successfully - it isn't just a simple question of conversion. So, no (not currently).

Also, whilst writing this answer, it dawned on me that unless someone has actually managed to automate the whole process already, then your question may merely invite opinions (rather than factual solutions).

From the link that you provided the conversion stages seem to be:

1. Obtain the LAZ file from LiDAR
2. LAZ to LAS
3. LAS to DSM
4. DSM to STL
5. STL to G-code

These stages would need to be put into an automated pipeline.

### Step 1

This step could be automated.

### Step 2

The LAZ to LAS seems to be a straightforward conversion using command line tools las2las, lasview and las2dem. This step probably could be automated (assuming that no manual intervention of the settings ​is required), as command line interfaces are easy to script (when compared with a GUI).

### Step 3

This step uses one of three GUI applications and looks like some manual labour (like adjusting settings) may be required, it is not clear. If the applications suggested by the article have APIs then a CLI option of automating the process could be possible - again it is not clear just by reading the article.

### Step 4

This step again uses a GUI (possibly to employ the export plugin and certainly to visualise the results) and so would appear to need some settings modifications and reiteration, to quote:

the conversion settings are something that will have to be explored via trial and error in order to figure out what is right for your dataset. In order to visualize the differences between the different settings you will have to open the .STL file into a software designed for 3D Printing.

### Step 5

While the use of a slicer can be automated (assuming that you have predefined (known parameters) thresholds), it usually requires some manual intervention (at least to begin with). If you google "automate slicing" then some interesting links appear, but usually they are for batch processing of similar objects/models.

### Summary

The language used in the steps above contains a lot of conditionals (may, can, could) because there are a lot of variables involved. A substantial amount of research would be required to get these elements of the pipeline to work together seamlessly. So, it is unlikely that a "point and click" solution exists where an STL file would just pop out at the end, with no manual intervention.

That said, if your LiDAR datasets were consistent (i.e. similar environments, similar objects being scanned) then you may be able to find a range of settings, for each stage, that work consistently well for a particular scenario. Then with these settings - in combination with some command line or Python scripting and/or an appropriate GUI scripting tool - you might be able to automate some, if not all, of the process.

Looking even further ahead, by using Machine Learning you may be able to train a model to learn to examine the visual feedback stages and then auto-tinker with the settings in order to get better results - however, whilst not in the realms of impossibility, it certainly is rather cutting edge (at this point in time). In a few years time though, it almost certainly will be possible.

The answer is highly depending on the programming skills of the programmer, but in theory, if all pieces of software exist, they can either be tied together in a workflow process (automated) or directly programmed into a new tool.