home products news downloads documentation support gallery online maps resellers search
TNTmips Downloads Menu

HOME

CONTACT US

CURRENT RELEASE
  TNT 2013

DEVELOPMENT VERSION
  TNT 2014

TNTmips Pro
PRIOR RELEASES
  TNT 2012

FREE SOFTWARE
  TNTmips Free
  TNTatlas
  TNTsdk

MORE DOWNLOADS
  HASP Key Driver
  Screen Recorder
  TNT Language Kits
  Sample Geodata
  TNT Scripts

DOCUMENTATION
  TNTmips Tutorials
  Tutorial Datasets
  Technical Guides
  Scripts
  Quick Guides

MORE INFO
  Download FAQs
  FTP
  Download Managers
  Find Reseller

SITE MAP


LAS_GROUND.sml



# LAS_GROUND.sml

# sample script demonstrating creating an LAS Lidar file and writing to it.
# LAS files are linked as Shape objects (class RVC_SHAPE).

# copies Lidar points classified as "Ground" (classification = 2) in an existing LAS file to a new LAS file.

# requires TNTmips version 2010 or higher.
# version 16 December 2009

clear();

# get input LAS shape object
class RVC_SHAPE lasIn;
class RVC_OBJITEM objItemIn;
DlgGetObject("Select input LAS shape object:", "Shape", objItemIn, "ExistingOnly");
lasIn.Open(objItemIn, "Read");

class RVC_GEOREFERENCE georef;		# get default georeference from input LAS file
lasIn.GetDefaultGeoref(georef);

# open input shape database and main table (table number = 0) for read
class RVC_DBASE_SHAPE dbIn;
dbIn.OpenAsSubobject(lasIn, "Read");

class RVC_DBTABLE tableIn;
tableIn.Open(dbIn, 0, "Read");
printf("Number of Fields in input LAS file = %d\n", tableIn.GetNumFields() );

# get filepath for output LAS file
class FILEPATH path = GetOutputFileName("output.las", "Select LAS file to make:", "las");

# make output LAS file for ground points; use method that takes the RVC_DBTABLE class
# instance for the existing LAS file to set the same point data record type for the new LAS file
class RVC_SHAPE lasOut;
lasOut.MakeLAS(path, georef.GetCoordRefSys(), tableIn); 

# open shape database and main table for write
class RVC_DBASE_SHAPE dbOut;
dbOut.OpenAsSubobject(lasOut, "Write");

class RVC_DBTABLE tableOut;
tableOut.Open(dbOut, 0, "Write");
printf("Number of Fields in output LAS file = %d\n", tableOut.GetNumFields() );

# record class instances for reading, copying, and writing records
class RVC_DBTABLE_RECORD recordIn(tableIn);
class RVC_DBTABLE_RECORD recordOut(tableOut);
class RVC_RECORDNUM recordNum;		# container for record number

class STATUSCONTEXT status;
class STATUSDIALOG statusDLG;
statusDLG.Create();
status = statusDLG.CreateContext();
status.BarInit(tableIn.GetNumRecords(), 0);
status.Message = "Processing LIDAR points...";

numeric i;									# loop counter

# loop through LIDAR point records to find points classified as ground
for i = 1 to tableIn.GetNumRecords()
	{
	if (i % 100000 == 0) printf("Processing record %d of %d\n", i, tableIn.GetNumRecords() );
	status.BarIncrement(1,0);

	recordNum.Number = i;
	tableIn.Read(recordNum, recordIn);		# read record from input LAS

	if (recordIn.GetValue(	"Classification")	 == 2)		# check value in Classification field, copy only ground points
		{
		recordIn.CopyTo(recordOut);			# copy field values from record in input to a new record for the output

		tableOut.AddRecord(recordOut);		# write the new record to output LAS file
		}
	}

statusDLG.Destroy();

printf("Number of ground points transferred to output = %d\n", tableOut.GetNumRecords() );
print("Done.");


Back Home ©MicroImages, Inc. 2013 Published in the United States of America
11th Floor - Sharp Tower, 206 South 13th Street, Lincoln NE 68508-2010   USA
Business & Sales: (402)477-9554  Support: (402)477-9562  Fax: (402)477-9559
Business info@microimages.com  Support support@microimages.com  Web webmaster@microimages.com

25 March 2009

page update: 26 May 11