Hello Wenyuan,
either you use the '-change_classification_from_to 2 4' transform that
is built into all LAStools such as
las2las -i lidar1.las -o lidar2.laz -change_classification_from_to 2 4
or - if you want to program it yourself - you follow the example code
given in this file here
C:\lastools\laslib\example\lasexample.cpp
and that would be something like the code below.
cheers,
martin @lastools
int main(int argc, char *argv[])
{
int i;
LASreadOpener lasreadopener;
LASwriteOpener laswriteopener;
if (argc == 1)
{
fprintf(stderr,"lasexample.exe is better run in the command line
\n");
char file_name[256];
fprintf(stderr,"enter input file: "); fgets(file_name, 256,
stdin);
file_name[strlen(file_name)-1] = '\0';
lasreadopener.set_file_name(file_name);
fprintf(stderr,"enter output file: "); fgets(file_name, 256,
stdin);
file_name[strlen(file_name)-1] = '\0';
laswriteopener.set_file_name(file_name);
}
else
{
lasreadopener.parse(argc, argv);
laswriteopener.parse(argc, argv);
}
// check input & output
if (!lasreadopener.active())
{
fprintf(stderr,"ERROR: no input specified\n");
return 1;
}
if (!laswriteopener.active())
{
fprintf(stderr,"ERROR: no output specified\n");
return 1;
}
// open lasreader
LASreader* lasreader = lasreadopener.open();
if (lasreader == 0)
{
fprintf(stderr, "ERROR: could not open lasreader\n");
return 1;
}
// open laswriter
LASwriter* laswriter = laswriteopener.open(&lasreader->header);
if (laswriter == 0)
{
fprintf(stderr, "ERROR: could not open laswriter\n");
return 1;
}
// when there is a point to read
while (lasreader->read_point())
{
// modify the point
lasreader->point.point_source_ID = 1020;
if (lasreader->point.classification == 12) lasreader-
>point.classification = 1;
// write the modified point
laswriter->write_point(&lasreader->point);
// add it to the inventory
laswriter->update_inventory(&lasreader->point);
}
laswriter->update_header(&lasreader->header, TRUE);
laswriter->close();
delete laswriter;
lasreader->close();
delete lasreader;