Hi Kevin,

I was able to run your code and convert the file to LAS with:
spdtranslate --if SPD --of LAS -i lidar.spd -o lidar.las

You need to index your SPD before loading it up in SPDPointsViewer, for example:
spdtranslate --if SPD --of SPD -x FIRST_RETURN -i lidar.spd -o lidar_seqind.spd

cheers,
John

From: Kevin Theuma [mailto:kevin.the...@um.edu.mt]
Sent: Thursday, 5 February 2015 6:47 PM
To: Daniel Clewley
Cc: spdlib-develop
Subject: Re: [spdlib-develop] Create new SPD file from python

Hi Daniel,
Thank you for your help.
I managed to solve the problem by setting some header values.
My new code is as follows...

import spdpy
spdFileOut = spdpy.createSPDFile("lidar.
spd")
spdWriter = spdpy.SPDPyNoIdxWriter()
spdWriter.open(spdFileOut, "lidar.spd")
spdFileOut.setReceiveWaveformDefined(0) # Define contents this lidar dataset
spdFileOut.setTransWaveformDefined(0)   # Define contents this lidar dataset
spdFileOut.setDecomposedPtDefined(0)    # Define contents this lidar dataset
spdFileOut.setDiscretePtDefined(1)      # Define contents this lidar dataset
spdFileOut.setOriginDefined(0)          # Define contents this lidar dataset
point1 = spdpy.createSPDPointPy()
point1.amplitudeReturn = 255
point1.x = 10
point1.y = 10
point1.z = 10
point2 = spdpy.createSPDPointPy()
point2.amplitudeReturn = 255
point2.x = 20
point2.y = 20
point2.z = 20
point3 = spdpy.createSPDPointPy()
point3.amplitudeReturn = 255
point3.x = 30
point3.y = 30
point3.z = 30
point4 = spdpy.createSPDPointPy()
point4.amplitudeReturn = 255
point4.x = 40
point4.y = 40
point4.z = 40
pulse = spdpy.createSPDPulsePy()
pulse.pts = [point1,point2,point3,point4]
pulse.numberOfReturns = 4
spdWriter.writeData([pulse])
spdWriter.close(spdFileOut)
spdpy.printSPDFile("lidar.spd")

However now I am getting a "Segmentation fault" error when trying to convert 
the SPD file to LAS and the SPDPointsViewer is not showing the points.
Regards,
Kevin

On 4 February 2015 at 21:42, Daniel Clewley 
<daniel.clew...@gmail.com<mailto:daniel.clew...@gmail.com>> wrote:
Hi Kevin,

Have you tried running spdinfo on the file (to check SPDLib can read it). I ran 
your code and the file read OK, I think the problem is just writing out to a 
LAS 1.2 file.

If you haven’t seen them already there are some examples of creating an SPD 
file using the Python bindings with the SPDLib source under python/importers

Thanks,

Dan


> On 4 Feb 2015, at 16:16, Kevin Theuma 
> <kevin.the...@um.edu.mt<mailto:kevin.the...@um.edu.mt>> wrote:
>
> Hi,
>
> I am creating a new SPD file from python but the output file is not being 
> recognised as a points file.
>
> My code is as follows...
>
> import spdpy
> spdFileOut = spdpy.createSPDFile("lidar.spd")
> spdWriter = spdpy.SPDPyNoIdxWriter()
> spdWriter.open(spdFileOut, "lidar.spd")
> point1 = spdpy.createSPDPointPy()
> point1.amplitudeReturn = 255
> point1.x = 10
> point1.y = 10
> point1.z = 10
> point2 = spdpy.createSPDPointPy()
> point2.amplitudeReturn = 255
> point2.x = 20
> point2.y = 20
> point2.z = 20
> point3 = spdpy.createSPDPointPy()
> point3.amplitudeReturn = 255
> point3.x = 30
> point3.y = 30
> point3.z = 30
> point4 = spdpy.createSPDPointPy()
> point4.amplitudeReturn = 255
> point4.x = 40
> point4.y = 40
> point4.z = 40
> pulse = spdpy.createSPDPulsePy()
> pulse.pts = [point1,point2,point3,point4]
> pulse.numberOfReturns = 4
> spdWriter.writeData([pulse])
> spdWriter.close(spdFileOut)
> spdpy.printSPDFile("lidar.spd")
>
> Whenever I try to convert the output SPD file to LAS spdtranslate gives me 
> this error:
> Error: This writer can only export point data.
>
> Is there something else I have to do to get it to work?
>
> Regards
> ------------------------------------------------------------------------------
> Dive into the World of Parallel Programming. The Go Parallel Website,
> sponsored by Intel and developed in partnership with Slashdot Media, is your
> hub for all things parallel software development, from weekly thought
> leadership blogs to news, videos, case studies, tutorials and more. Take a
> look and join the conversation now. 
> http://goparallel.sourceforge.net/_______________________________________________
> spdlib-develop mailing list
> spdlib-develop@lists.sourceforge.net<mailto:spdlib-develop@lists.sourceforge.net>
> https://lists.sourceforge.net/lists/listinfo/spdlib-develop




--

Kevin Theuma
B.Eng. (Hons)(Melit.)
Research Support Officer

Room 318
Department of Electronic Systems Engineering
Faculty of Engineering
University of Malta, Msida MSD 2080, Malta
Tel: (+356) 2340 3905
E-mail: kevin.the...@um.edu.mt<mailto:kevin.the...@um.edu.mt>
This E-Mail is intended only for the addressee. Its use is limited to that 
intended by the author at the time and it is not to be distributed without the 
author's consent. Unless otherwise stated, the State of Queensland accepts no 
liability for the contents of this E-Mail except where subsequently confirmed 
in writing. The opinions expressed in this E-Mail are those of the author and 
do not necessarily represent the views of the State of Queensland. This E-Mail 
is confidential and may be subject to a claim of legal privilege. If you have 
received this E-Mail in error, please notify the author and delete this message 
immediately.
------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
spdlib-develop mailing list
spdlib-develop@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spdlib-develop

Reply via email to