<div dir="ltr">Hello Pol,<div><br></div><div>attached is sample code that uses LASlib to read a LAS / LAZ file with point type 0, 1, or 4, add RGB colors, and write a LAS / LAZ file with point type 2, 3, or 5 respectively. This lasexample_add_rgb.cpp source code has also been added as a new permanent example of LASlib use to the ./LAStools/LASlib/example folder and can be accessed via github here:</div><div><br></div><div><a href="http://github.com/LAStools/LAStools/tree/master/LASlib">http://github.com/LAStools/LAStools/tree/master/LASlib</a><br></div><div><br></div><div>Regards,</div><div><br></div><div>Martin @rapidlasso</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Apr 8, 2016 at 1:02 PM, Pol Monsó Purtí <span dir="ltr"><<a href="mailto:lluna.nova@gmail.com" target="_blank">lluna.nova@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div>I was wrong.<br><br></div>The init is not sufficient because the header itself stores the point data format and size. <br><br></div>If I set them in a copy of the header that I then pass to the init, I get a segfault on the first point write, third writer. Probably because the size of the points is in fact incorrect.<br><br></div>Anybody willing to weight in?...?<br></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Apr 5, 2016 at 6:12 PM, Pol Monsó Purtí <span dir="ltr"><<a href="mailto:lluna.nova@gmail.com" target="_blank">lluna.nova@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Ok, it seems I should create a new point and call to init, as seen on the <i>writer only</i> example.<br><br></div><div>In my case, the output point data record format is 3, with a size of <span>34.<br><br></span></div><div><span>Therefore:</span><br>

<p style="margin:0px;text-indent:0px"><br></p>
<pre style="margin:0px;text-indent:0px"><span style="color:rgb(100,100,130)">  </span><span style="color:rgb(255,139,255)">LASpoint</span><span style="color:rgb(100,100,130)"> </span>p<span style="color:rgb(207,191,173)">;</span></pre>
<pre style="margin:0px;text-indent:0px"><span style="color:rgb(100,100,130)">  </span>laspoint<span style="color:rgb(207,191,173)">.</span>init<span style="color:rgb(207,191,173)">(&</span>lasreader<span style="color:rgb(207,191,173)">-></span><span style="font-weight:600">header</span><span style="color:rgb(207,191,173)">,</span><span style="color:rgb(100,100,130)"> </span>PointDataFormatID_2<span style="color:rgb(207,191,173)">,</span><span style="color:rgb(100,100,130)"> </span>PointDataFormatSize<span style="color:rgb(207,191,173)">,</span><span style="color:rgb(100,100,130)"> </span><span style="color:rgb(240,173,109)">0</span><span style="color:rgb(207,191,173)">);</span></pre>
<pre style="margin:0px;text-indent:0px"><span style="font-family:arial,helvetica,sans-serif"><br></span></pre><pre style="margin:0px;text-indent:0px"><span style="font-family:arial,helvetica,sans-serif">with 2 and 34. Is that correct? Do I have to manually change the header to activate have_rgb?</span><br></pre></div><div><span><br></span></div><div><span>Is that the way to do this?<br><br></span></div><div><span>Do I have to guarantee the existence of the LASpoint memory until the close or just until the write? (effectively reusing it after each iteration)<br><br></span></div><div><span>What happens if I call init on the LASpoint* of the reader?<br></span></div><div><span><br></span></div><div><span>Cheers,<br><br></span></div><div><span>Pol<br></span></div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Apr 5, 2016 at 5:27 PM, Pol Monsó Purtí <span dir="ltr"><<a href="mailto:lluna.nova@gmail.com" target="_blank">lluna.nova@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Ok, it definetly has to do something about the header or the point type. If I take in a cloud with rgb I can change it and save it. And it does have the RGB12_LE writer in its vector.<br><br></div>Now, how can I tell liblas to add this writer on the writer if it ain't there on the reader?<br></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Apr 5, 2016 at 5:02 PM, Pol Monsó Purtí <span dir="ltr"><<a href="mailto:lluna.nova@gmail.com" target="_blank">lluna.nova@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>I've debugged the application and the point p has the rgb, but I couldn't find where it is written. <br><br></div><div>It is probably at LASwriteItemRaw_POINT10_LE, which is the writer that gets called from the writers vector. Does LAS 1.0 support color? If not, how do I set the LAS specification?<br><br></div><div>The input cloud is supposed to be las 1.2. I've added the following line after the writing loop and before the close, so that I don't get the npoints mismatch error:<br><br><span style="color:rgb(100,100,130)">  </span><span style="font-family:monospace,monospace">laswriter<span style="color:rgb(207,191,173)">-></span><span style="font-style:italic">update_header</span><span style="color:rgb(207,191,173)">(&</span>lasreader<span style="color:rgb(207,191,173)">-></span><span style="font-weight:600">header</span><span style="color:rgb(207,191,173)">,</span><span style="color:rgb(100,100,130)"> </span><span style="color:rgb(64,144,144)">TRUE</span><span style="color:rgb(207,191,173)">);</span>
</span><pre style="margin:0px;text-indent:0px"><br></pre><br></div><div><br>Btw, I forget to mention that I'm on windows<br></div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Apr 5, 2016 at 4:53 PM, Pol Monsó Purtí <span dir="ltr"><<a href="mailto:lluna.nova@gmail.com" target="_blank">lluna.nova@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I want to colorize a colorless las cloud, but I get only 0 as rgb. Is there a parameter that must be set (e.g. has_rgb)?<br><br>I am currently doing the following:<br><br><span style="color:rgb(100,100,130)">     </span><span style="font-family:monospace,monospace"><span style="color:rgb(255,139,255)">LASreadOpener</span><span style="color:rgb(100,100,130)"> </span>lasreadopener<span style="color:rgb(207,191,173)">;</span>
</span><pre style="margin:0px;text-indent:0px"><span style="font-family:monospace,monospace"><span style="color:rgb(100,100,130)">  </span>lasreadopener<span style="color:rgb(207,191,173)">.</span>set_file_name<span style="color:rgb(207,191,173)">(</span>infilename<span style="color:rgb(207,191,173)">);</span></span></pre><span style="font-family:monospace,monospace">
</span><pre style="margin:0px;text-indent:0px"><span style="font-family:monospace,monospace"><span style="color:rgb(100,100,130)">  </span><span style="color:rgb(255,139,255)">LASreader</span><span style="color:rgb(207,191,173)">*</span><span style="color:rgb(100,100,130)"> </span>lasreader<span style="color:rgb(100,100,130)"> </span><span style="color:rgb(207,191,173)">=</span><span style="color:rgb(100,100,130)"> </span>lasreadopener<span style="color:rgb(207,191,173)">.</span>open<span style="color:rgb(207,191,173)">();</span></span></pre><span style="font-family:monospace,monospace">
</span><pre style="margin:0px;text-indent:0px"><span style="font-family:monospace,monospace"><br></span></pre><span style="font-family:monospace,monospace">
</span><pre style="margin:0px;text-indent:0px"><span style="font-family:monospace,monospace"><span style="color:rgb(100,100,130)">  </span><span style="color:rgb(255,139,255)">LASwriteOpener</span><span style="color:rgb(100,100,130)"> </span>laswriteopener<span style="color:rgb(207,191,173)">;</span></span></pre><span style="font-family:monospace,monospace">
</span><pre style="margin:0px;text-indent:0px"><span style="font-family:monospace,monospace"><span style="color:rgb(100,100,130)">  </span>laswriteopener<span style="color:rgb(207,191,173)">.</span>set_file_name<span style="color:rgb(207,191,173)">(</span><span style="color:rgb(255,205,139);background-color:rgb(64,64,64)">"test.las"</span><span style="color:rgb(207,191,173)">);</span></span></pre><span style="font-family:monospace,monospace">
</span><pre style="margin:0px;text-indent:0px"><span style="font-family:monospace,monospace"><span style="color:rgb(100,100,130)">  </span><span style="color:rgb(255,139,255)">LASwriter</span><span style="color:rgb(207,191,173)">*</span><span style="color:rgb(100,100,130)"> </span>laswriter<span style="color:rgb(100,100,130)"> </span><span style="color:rgb(207,191,173)">=</span><span style="color:rgb(100,100,130)"> </span>laswriteopener<span style="color:rgb(207,191,173)">.</span>open<span style="color:rgb(207,191,173)">(&</span>lasreader<span style="color:rgb(207,191,173)">-></span><span style="font-weight:600">header</span><span style="color:rgb(207,191,173)">);</span></span></pre><span style="font-family:monospace,monospace">
</span><pre style="margin:0px;text-indent:0px"><span style="font-family:monospace,monospace"><br>[...]<br></span></pre><span style="font-family:monospace,monospace"><br>  lasreader<span style="color:rgb(207,191,173)">-></span><span style="font-style:italic">seek</span><span style="color:rgb(207,191,173)">(</span><span style="color:rgb(240,173,109)">0</span><span style="color:rgb(207,191,173)">);</span>
</span><pre style="margin:0px;text-indent:0px"><span style="font-family:monospace,monospace"><br></span></pre><span style="font-family:monospace,monospace">
</span><pre style="margin:0px;text-indent:0px"><span style="font-family:monospace,monospace"><span style="color:rgb(100,100,130)">  </span><span style="color:rgb(255,139,255)">U16</span><span style="color:rgb(100,100,130)"> </span>rgb<span style="color:rgb(207,191,173)">[</span><span style="color:rgb(240,173,109)">4</span><span style="color:rgb(207,191,173)">];<br></span></span></pre><pre style="margin:0px;text-indent:0px"><span style="font-family:monospace,monospace"><span style="color:rgb(207,191,173)">  U16 colur = 100;<br></span></span></pre><span style="font-family:monospace,monospace">
</span><pre style="margin:0px;text-indent:0px"><span style="font-family:monospace,monospace"><br></span></pre><span style="font-family:monospace,monospace">
</span><pre style="margin:0px;text-indent:0px"><span style="font-family:monospace,monospace"><span style="color:rgb(100,100,130)">  </span><span style="color:rgb(128,139,237)">for</span><span style="color:rgb(207,191,173)">(</span><span style="color:rgb(128,139,237)">int</span><span style="color:rgb(100,100,130)"> </span>i<span style="color:rgb(100,100,130)"> </span><span style="color:rgb(207,191,173)">=</span><span style="color:rgb(100,100,130)"> </span><span style="color:rgb(240,173,109)">0</span><span style="color:rgb(207,191,173)">;</span><span style="color:rgb(100,100,130)"> </span>i<span style="color:rgb(100,100,130)"> </span><span style="color:rgb(207,191,173)"><</span><span style="color:rgb(100,100,130)"> </span>npoints<span style="color:rgb(207,191,173)">;</span><span style="color:rgb(100,100,130)"> </span>i<span style="color:rgb(207,191,173)">++)</span></span></pre><span style="font-family:monospace,monospace">
</span><pre style="margin:0px;text-indent:0px"><span style="font-family:monospace,monospace"><span style="color:rgb(100,100,130)">  </span><span style="color:rgb(207,191,173)">{</span></span></pre><span style="font-family:monospace,monospace">
</span><pre style="margin:0px;text-indent:0px"><span style="font-family:monospace,monospace"><span style="color:rgb(100,100,130)">    </span>lasreader<span style="color:rgb(207,191,173)">-></span>read_point<span style="color:rgb(207,191,173)">();</span></span></pre><span style="font-family:monospace,monospace">
</span><pre style="margin:0px;text-indent:0px"><span style="font-family:monospace,monospace"><span style="color:rgb(100,100,130)">    </span><span style="color:rgb(255,139,255)">LASpoint</span><span style="color:rgb(100,100,130)"> </span><span style="color:rgb(207,191,173)">*</span>p<span style="color:rgb(100,100,130)"> </span><span style="color:rgb(207,191,173)">=</span><span style="color:rgb(100,100,130)"> </span><span style="color:rgb(207,191,173)">&</span>lasreader<span style="color:rgb(207,191,173)">-></span><span style="font-weight:600">point</span><span style="color:rgb(207,191,173)">;</span></span></pre><span style="font-family:monospace,monospace"><span style="color:rgb(100,100,130)">    </span>rgb<span style="color:rgb(207,191,173)">[</span><span style="color:rgb(240,173,109)">0</span><span style="color:rgb(207,191,173)">]</span><span style="color:rgb(100,100,130)"> </span><span style="color:rgb(207,191,173)">=</span><span style="color:rgb(100,100,130)"> </span><span style="color:rgb(207,191,173)">colur</span><span style="color:rgb(207,191,173)">;</span>
</span><pre style="margin:0px;text-indent:0px"><span style="font-family:monospace,monospace"><span style="color:rgb(100,100,130)">    </span>rgb<span style="color:rgb(207,191,173)">[</span><span style="color:rgb(240,173,109)">1</span><span style="color:rgb(207,191,173)">]</span><span style="color:rgb(100,100,130)"> </span><span style="color:rgb(207,191,173)">=</span><span style="color:rgb(100,100,130)"> </span><span style="color:rgb(207,191,173)">colur</span><span style="color:rgb(207,191,173)">;</span></span></pre><span style="font-family:monospace,monospace">
</span><pre style="margin:0px;text-indent:0px"><span style="font-family:monospace,monospace"><span style="color:rgb(100,100,130)">    </span>rgb<span style="color:rgb(207,191,173)">[</span><span style="color:rgb(240,173,109)">2</span><span style="color:rgb(207,191,173)">]</span><span style="color:rgb(100,100,130)"> </span><span style="color:rgb(207,191,173)">=</span><span style="color:rgb(100,100,130)"> </span><span style="color:rgb(207,191,173)">colur</span></span><span style="font-family:monospace,monospace"><span style="color:rgb(207,191,173)">;</span></span></pre><span style="font-family:monospace,monospace">
</span><pre style="margin:0px;text-indent:0px"><span style="font-family:monospace,monospace"><span style="color:rgb(100,100,130)">    </span>rgb<span style="color:rgb(207,191,173)">[</span><span style="color:rgb(240,173,109)">3</span><span style="color:rgb(207,191,173)">]</span><span style="color:rgb(100,100,130)"> </span><span style="color:rgb(207,191,173)">=</span><span style="color:rgb(100,100,130)"> </span><span style="color:rgb(240,173,109)">0</span><span style="color:rgb(207,191,173)">;</span></span></pre><span style="font-family:monospace,monospace">
</span><pre style="margin:0px;text-indent:0px"><span style="font-family:monospace,monospace"><span style="color:rgb(100,100,130)">    </span>p<span style="color:rgb(207,191,173)">-></span>set_rgb<span style="color:rgb(207,191,173)">(</span>rgb<span style="color:rgb(207,191,173)">);</span></span></pre><span style="font-family:monospace,monospace">
</span><pre style="margin:0px;text-indent:0px"><span style="font-family:monospace,monospace"><span style="color:rgb(100,100,130)">    </span>laswriter<span style="color:rgb(207,191,173)">-></span><span style="font-style:italic">write_point</span><span style="color:rgb(207,191,173)">(</span>p<span style="color:rgb(207,191,173)">);</span></span></pre><span style="font-family:monospace,monospace"></span><span style="font-family:monospace,monospace"></span><span style="font-family:monospace,monospace"></span><span style="font-family:monospace,monospace"><span style="color:rgb(100,100,130)">  </span><span style="color:rgb(207,191,173)">}</span></span><span style="font-family:monospace,monospace">
</span><pre style="margin:0px;text-indent:0px"><br></pre><span style="font-family:monospace,monospace">
</span><pre style="margin:0px;text-indent:0px"><span style="font-family:monospace,monospace"><br></span></pre><span style="font-family:monospace,monospace">
</span><pre style="margin:0px;text-indent:0px"><span style="font-family:monospace,monospace"><span style="color:rgb(100,100,130)">  </span><span style="color:rgb(255,139,255)">I64</span><span style="color:rgb(100,100,130)"> </span>total_bytes<span style="color:rgb(100,100,130)"> </span><span style="color:rgb(207,191,173)">=</span><span style="color:rgb(100,100,130)"> </span>laswriter<span style="color:rgb(207,191,173)">-></span><span style="font-style:italic">close</span><span style="color:rgb(207,191,173)">();</span></span></pre><span style="font-family:monospace,monospace">
</span><pre style="margin:0px;text-indent:0px"><span style="font-family:monospace,monospace"><span style="color:rgb(100,100,130)">  </span><span style="color:rgb(128,139,237)">delete</span><span style="color:rgb(100,100,130)"> </span>laswriter<span style="color:rgb(207,191,173)">;</span></span></pre><span style="font-family:monospace,monospace"><br><span style="color:rgb(100,100,130)">  </span>lasreader<span style="color:rgb(207,191,173)">-></span><span style="font-style:italic">close</span><span style="color:rgb(207,191,173)">();</span>
</span><pre style="margin:0px;text-indent:0px"><span style="font-family:monospace,monospace"><span style="color:rgb(100,100,130)">  </span><span style="color:rgb(128,139,237)">delete</span><span style="color:rgb(100,100,130)"> </span>lasreader<span style="color:rgb(207,191,173)">;</span></span></pre></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>

<p></p>

-- <br>
Download LAStools at<br>
<a href="http://lastools.org" target="_blank">http://lastools.org</a><br>
<a href="http://rapidlasso.com" target="_blank">http://rapidlasso.com</a><br>
Be social with LAStools at<br>
<a href="http://facebook.com/LAStools" target="_blank">http://facebook.com/LAStools</a><br>
<a href="http://twitter.com/LAStools" target="_blank">http://twitter.com/LAStools</a><br>
<a href="http://linkedin.com/groups/LAStools-4408378" target="_blank">http://linkedin.com/groups/LAStools-4408378</a><br>
Manage your settings at<br>
<a href="http://groups.google.com/group/lastools/subscribe" target="_blank">http://groups.google.com/group/lastools/subscribe</a><br>
</div></div></blockquote></div><br></div>