POV-Ray : Newsgroups : povray.tools.general : Asking for a tool to transform .txt(x,y,z) data to POV format : Re: Asking for a tool to transform .txt(x,y,z) data to POV format Server Time
21 Sep 2021 06:55:17 EDT (-0400)
  Re: Asking for a tool to transform .txt(x,y,z) data to POV format  
From: Tor Olav Kristensen
Date: 28 May 2016 23:30:00
Message: <web.574a610895276ce9ccadeeb30@news.povray.org>
"Mengshi" <rsy### [at] gmailcom> wrote:
> Dear all,
>
> I want to use the POV-RAY with LIDAR dara. The format of Lidar data could be
> ascii file (txt,csv), or las/laz,all including X,Y,Z.
>  So do you have any recommend tools for transforming xyz data into .pov format??
>
>
> Thanks a lot.


If you have access to 'sed', 'tail' and a shell (e.g. in Linux or Cygwin), you
can do this:

you@linux:~$ tail -n +2 lidar.txt | sed s/' '/', '/g | sed s/$/','/ >lidar.csv

('lidar.txt' is the file with your original lidar data.)
A file 'lidar.csv' will then be created, which can be read from a POV-Ray script
like this:


#version 3.7;

#declare NrOfPoints = 4162388;
#declare Points = array[NrOfPoints];

#fopen LidarFile "lidar.csv" read

#declare Cnt = 0;
#while (defined(LidarFile) & Cnt < NrOfPoints)
    #read (LidarFile, X, Y, Z)
    #declare Points[Cnt] = <X, Y, Z>;
    #declare Cnt = Cnt + 1;
#end // for

#fclose LidarFile

#for (Cnt, 0, NrOfPoints-1)
    #debug "\n"
    #debug concat("Point no. ", str(Cnt, 0, 0), ": ")
    #debug concat("<", vstr(3, Points[Cnt], ", ", 0, -1), ">")
#end // for
#debug "\n\n"


And if you have access to 'wc' you can get the number of lines in the lidar.csv
file like this:

you@linux:~$ wc --lines lidar.csv


--
Tor Olav
http://subcube.com


Post a reply to this message

Copyright 2003-2021 Persistence of Vision Raytracer Pty. Ltd.