Creating LAS Datasets from .LAS files then convert each individual .las file to a tin

1188
0
02-12-2018 01:57 PM
ShannonBradley
New Contributor

This question was asked before a little while ago. I need to do the exact same thing, take .las files, make each of them their own .lasd file, and then create tin models based from the .lasd files. The very last code given for the previous time this question was asked is this :

  1. import os  
  2. import arcpy  
  3. import glob  
  4.   
  5. # this is a folder containing .las files  
  6. ws = r'C:\some_path\to_your\las_files'    
  7.   
  8. # get list of .las files  
  9. inLas = glob.glob(os.path.join(ws, '*.las'))  
  10. print 'found {0} .las files'.format(len(inLas))  
  11. print inLas  
  12.   
  13. # directories  
  14. lasd_dir = r'C:\some_path\for_lasd_files'  
  15. tin_dir = os.path.join(lasd_dir, 'tins')  
  16. if not os.path.exists(tin_dir):  
  17.     os.makedirs(tin_dir)  
  18.   
  19. # iterate through .las files  
  20. for las in inLas:  
  21.     lasD = os.path.join(lasd_dir, os.path.basename(las) + 'd')  
  22.     arcpy.management.CreateLasDataset(inLas,lasD)  
  23.     print 'Created Las dataset: {0}'.format(lasD)  
  24.     out_tin = os.path.join(tin_dir, os.path.basename(las).split('.')[0][:9] + '_tin')  
  25.     arcpy.LasDatasetToTin_3d(lasD, out_tin)  
  26.     print 'Created tin: {0}'.format(out_tin)  
  27.   
  28. print 'Process complete.'  

I created a python toolbox and added the script into it in arcmap but I am not sure if this is the exact code I want for the tool. I changed the locations for files and the *.las to the correct files. When I execute it, the folders show up for my lasd and tins but the only other output is a single .lasd file of the .las files combined. 

If anyone can help revise the script that would be greatly appreciated!

0 Kudos
0 Replies