original_docstring: 
      Takes every las file in the data_folder and creates 9 raster products from it (and
      a swapped xyrz las file).
      Each las gets its own subfolder
  
      Args:
          data_folder: the directory that contains the las files
          products_folder: the directory to write the products to
          resolution: the resolution of the products to be written
          remove_buildings: a boolean indicating if buildings should not be included in the dsm (and dhm) assuming
                            that they are classified in the las file
      Returns: None
  
      
docstring: Takes every las file in the data_folder and creates 9 raster products from it (and
  a swapped xyrz las file).
  Each las gets its own subfolder
docstring_tokens: Takes every las file in the data_folder and creates 9 raster products from it ( and a swapped xyrz las file ) . Each las gets its own subfolder
code: def rasteration(data_folder, products_folder, resolution=1, remove_buildings=True, overwrite=False):
      """
      Takes every las file in the data_folder and creates 9 raster products from it (and
      a swapped xyrz las file).
      Each las gets its own subfolder
  
      Args:
          data_folder: the directory that contains the las files
          products_folder: the directory to write the products to
          resolution: the resolution of the products to be written
          remove_buildings: a boolean indicating if buildings should not be included in the dsm (and dhm) assuming
                            that they are classified in the las file
      Returns: None
  
      """
  
      files = os.listdir(data_folder)
  
      if not isinstance(files, list):
          files = [files]
      n_files = len(files)
  
      start = time.time()
      problems = []
      for i,file in enumerate(files):
          intermediate1 = time.time()
          filename = os.path.join(data_folder, file)
          new_folder = os.path.join(products_folder, file)[:-4]  # sans .las
          if not os.path.exists(new_folder):
              os.mkdir(new_folder)
          elif overwrite:
              print(f'{file} exists. Folder will be overwritten.')
              shutil.rmtree(new_folder)
              os.mkdir(new_folder)
          outname = os.path.join(new_folder, file)[:-4]  # sans .las
  
          print(f'Creating products for {file}')
  
          demname = outname+'_digel.tif'
          dsmname = outname + '_digsm.tif'
          nreturnsname = outname + '_nretu.tif'
          intensityname = outname + '_inten.tif'
  
          block_print()  # wbt has EXTREMELY obnoxious printouts
  
          if not os.path.exists(nreturnsname):
              # use laspy to store the return number in the user_data field
              try:
                  with laspy.file.File(filename, mode="rw") as in_file:
                      in_file.user_data = copy(in_file.return_num)
              except TypeError:
                  print(f'A TypeError occurred while attempting to modify {file}. Skipping')
                  problems.append(file)
                  pass
              except ValueError:
                  print(f'A ValueError occurred while attempting to modify {file}. Skipping')
                  problems.append(file)
                  pass
              wbt.lidar_tin_gridding(i=filename, output=nreturnsname, parameter='user data',
                                     returns='last', resolution=resolution, exclude_cls='7,18')  # , exclude_cls='7,13,14,18'
  
          # make the digital elevation model (trees, etc. removed)
          if not os.path.exists(demname):
              wbt.lidar_tin_gridding(i=filename, output=demname, parameter='elevation',
                                     returns='last', resolution=resolution, exclude_cls='7,18')  # , exclude_cls=keep([2,9,11]) only keep ground road water
  
          # make the digital surface model
          # keep everything except noise and wires and maybe buildings
          if not os.path.exists(dsmname):
              if remove_buildings:
                  cls = '6,7,13,14,18'
              else:
                  cls = '7,13,14,18'
              wbt.lidar_tin_gridding(i=filename, output=dsmname, parameter='elevation',
                                     returns='first', resolution=resolution, exclude_cls='7,18')  # , exclude_cls=cls
  
  
          # make the intensity model (trees, etc. removed)
          if not os.path.exists(intensityname):
              wbt.lidar_tin_gridding(i=filename, output=intensityname, parameter='intensity',
                                     returns='all', resolution=resolution, exclude_cls='7,18')  # , exclude_cls=keep([2,9,11]) only keep ground road water
  
          # timing
          enable_print()
          intermediate2 = time.time()
          intermediate_elap = round(intermediate2-intermediate1, 2) # in seconds
          running_time = round(intermediate2-start, 2)/60 # in minutes
          frac_progress = (i+1)/n_files
          estimated_total_time = round(running_time*(1/frac_progress) - running_time, 2)
  
          print(f'Processing time: {intermediate_elap} seconds. File {i+1} of {n_files} complete. Estimated time remaining: '
                f'{estimated_total_time} minutes')
  
      final = time.time()
      elap = round(final-start, 2)
      print(f'FINISHED. Elapsed time: {elap/60} minutes')
      print(f'Problem files:')
      print(problems)
code_tokens: def rasteration ( data_folder , products_folder , resolution = 1 , remove_buildings = True , overwrite = False ) : files = os . listdir ( data_folder ) if not isinstance ( files , list ) : files = [ files ] n_files = len ( files ) start = time . time ( ) problems = [ ] for i , file in enumerate ( files ) : intermediate1 = time . time ( ) filename = os . path . join ( data_folder , file ) new_folder = os . path . join ( products_folder , file ) [ : - 4 ] if not os . path . exists ( new_folder ) : os . mkdir ( new_folder ) elif overwrite : print ( f'{file} exists. Folder will be overwritten.' ) shutil . rmtree ( new_folder ) os . mkdir ( new_folder ) outname = os . path . join ( new_folder , file ) [ : - 4 ] print ( f'Creating products for {file}' ) demname = outname + '_digel.tif' dsmname = outname + '_digsm.tif' nreturnsname = outname + '_nretu.tif' intensityname = outname + '_inten.tif' block_print ( ) if not os . path . exists ( nreturnsname ) : try : with laspy . file . File ( filename , mode = "rw" ) as in_file : in_file . user_data = copy ( in_file . return_num ) except TypeError : print ( f'A TypeError occurred while attempting to modify {file}. Skipping' ) problems . append ( file ) pass except ValueError : print ( f'A ValueError occurred while attempting to modify {file}. Skipping' ) problems . append ( file ) pass wbt . lidar_tin_gridding ( i = filename , output = nreturnsname , parameter = 'user data' , returns = 'last' , resolution = resolution , exclude_cls = '7,18' ) if not os . path . exists ( demname ) : wbt . lidar_tin_gridding ( i = filename , output = demname , parameter = 'elevation' , returns = 'last' , resolution = resolution , exclude_cls = '7,18' ) if not os . path . exists ( dsmname ) : if remove_buildings : cls = '6,7,13,14,18' else : cls = '7,13,14,18' wbt . lidar_tin_gridding ( i = filename , output = dsmname , parameter = 'elevation' , returns = 'first' , resolution = resolution , exclude_cls = '7,18' ) if not os . path . exists ( intensityname ) : wbt . lidar_tin_gridding ( i = filename , output = intensityname , parameter = 'intensity' , returns = 'all' , resolution = resolution , exclude_cls = '7,18' ) enable_print ( ) intermediate2 = time . time ( ) intermediate_elap = round ( intermediate2 - intermediate1 , 2 ) running_time = round ( intermediate2 - start , 2 ) / 60 frac_progress = ( i + 1 ) / n_files estimated_total_time = round ( running_time * ( 1 / frac_progress ) - running_time , 2 ) print ( f'Processing time: {intermediate_elap} seconds. File {i+1} of {n_files} complete. Estimated time remaining: ' f'{estimated_total_time} minutes' ) final = time . time ( ) elap = round ( final - start , 2 ) print ( f'FINISHED. Elapsed time: {elap/60} minutes' ) print ( f'Problem files:' ) print ( problems )
short_docstring: Takes every las file in the data_folder and creates 9 raster products from it (and
  a swapped xyrz las file).
short_docstring_tokens: Takes every las file in the data_folder and creates 9 raster products from it ( and a swapped xyrz las file ) .
comment: """
      Takes every las file in the data_folder and creates 9 raster products from it (and
      a swapped xyrz las file).
      Each las gets its own subfolder
  
      Args:
          data_folder: the directory that contains the las files
          products_folder: the directory to write the products to
          resolution: the resolution of the products to be written
          remove_buildings: a boolean indicating if buildings should not be included in the dsm (and dhm) assuming
                            that they are classified in the las file
      Returns: None
  
      """$SEP$# sans .las$SEP$# sans .las$SEP$# wbt has EXTREMELY obnoxious printouts$SEP$# use laspy to store the return number in the user_data field$SEP$# , exclude_cls='7,13,14,18'$SEP$# make the digital elevation model (trees, etc. removed)$SEP$# , exclude_cls=keep([2,9,11]) only keep ground road water$SEP$# make the digital surface model$SEP$# keep everything except noise and wires and maybe buildings$SEP$# , exclude_cls=cls$SEP$# make the intensity model (trees, etc. removed)$SEP$# , exclude_cls=keep([2,9,11]) only keep ground road water$SEP$# timing$SEP$# in seconds$SEP$# in minutes