Split Cyclone PTS/PTX files into individual scans

549 views
Skip to first unread message

John Wall

unread,
Feb 17, 2016, 12:58:16 PM2/17/16
to LAStools - efficient tools for LiDAR processing
Hello all,
I am using Cyclone 5.1 to export my terrestrial lidar data to PTS and PTX formats and then convert it to LAS format using pointzip.exe. However, I have multiple scans within one PTS/PTX file and would like to split them up into their respective scans. For example, I would like one PTS file to contain Scan 1, Scan 2...etc. Is this possible? Is this functionality already within pointzip.exe?
Thanks,
John

Martin Isenburg

unread,
Feb 19, 2016, 5:48:35 PM2/19/16
to LAStools - efficient command line tools for LIDAR processing
Hello John.

this funcitonality is not in http://pointzip.org yet. When I did the programming of pointzip.exe I assumed that each PTS / PTX file contains just one unstructured (PTS) / gridded (PTX) point cloud. But as both PTS and PTX are simple ASCII formats it should be easy to write some perl / python / ... script that can find the places where they can be segmented into multiple files. With so many scripting enthusiasts in this forum I am sure there is someone who either has such a script already or can write one in a few minutes. Some more info on the PTS / PTX formats and pointzip.exe is here:

http://www.laserscanningforum.com/forum/viewtopic.php?f=144&t=7169

Regards,

Martin @rapidlasso

Terje Mathisen

unread,
Feb 20, 2016, 4:09:34 AM2/20/16
to last...@googlegroups.com
Martin Isenburg wrote:
> Hello John.
>
> this funcitonality is not in http://pointzip.org yet. When I did the
> programming of pointzip.exe I assumed that each PTS / PTX file
> contains just one unstructured (PTS) / gridded (PTX) point cloud. But
> as both PTS and PTX are simple ASCII formats it should be easy to
> write some perl / python / ... script that can find the places where
> they can be segmented into multiple files. With so many scripting
> enthusiasts in this forum I am sure there is someone who either has
> such a script already or can write one in a few minutes. Some more
> info on the PTS / PTX formats and pointzip.exe is here:

That's a challenge if I ever saw one. :-)

Try this perl script, ptx-split.pl

It assumes that each segment starts with the same ype of startup block
of 10 lines, I tested it by concatenating a few of the samples you
pointed us at and ran it like this:

ptx-split.pl samples.ptx ptx

This generated ptx_000.ptx, ptx_001.ptx etc.

#!perl -w
# ptx-split.pl, written by Terje Mathisen
use strict;

my $ifile = shift;
my $oprefix = shift;
die("Usage: ptx-split.pl <input_filename> <output_prefix>\n") unless
(defined($oprefix) && open(I, $ifile));

my ($part, $lines, $ofile) = (0,1e38);

while (<I>) {
chomp;
my @f = split;
if (scalar(@f) == 1 && $lines >= 10) { # Start of new PTX segment

close(O) if ($lines < 1e38);
my $ofile = sprintf(">%s_%03d.ptx", $oprefix, $part++);
open(O, $ofile) || die("Could not write to $ofile\n");
$lines = 0;
}
printf(O "%s\n", $_) || die("Error writing output\n");
$lines++;
}
close(O) if ($lines < 1e38);
--
- <Terje.M...@tmsw.no>
"almost all programming can be viewed as an exercise in caching"

Reply all
Reply to author
Forward
0 new messages