<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><br></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, May 14, 2020 at 6:50 PM Miguel Guerrero <<a href="mailto:g.miguel.guerrero.m@gmail.com">g.miguel.guerrero.m@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Thanks for the prompt reply!<div>I understand. Here is another question: I stored the Coplanarity values (0 and 1) in the UserData dimension. Is there any way to "assign"/"reclassify" the UserData dimension to the Classification dimension?</div><div>Example:</div><div>UserData = 0 => Classification = class 16</div><div>UserData = 1 => Classification = class 17</div></div></blockquote><div><br></div><div>You can do this with the assign filter:</div><div><br></div><div>{</div><div>  "type" : "filters.assign",</div><div>  "assignment": "Classification[:]=16",</div><div>  "condition":"UserData[0:0]"</div><div>},</div><div><div>{</div><div>  "type" : "filters.assign",</div><div>  "assignment": "Classification[:]=17",</div><div>  "condition":"UserData[1:1]"</div><div>},</div></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><br></div><div>Thanks in advance for your help</div><div><br></div><div>Miguel</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, May 14, 2020 at 1:01 PM Andrew Bell <<a href="mailto:andrew.bell.ia@gmail.com" target="_blank">andrew.bell.ia@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">filters.csf is a ground filter, so it classifies everything as either ground or unclassified.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, May 14, 2020 at 3:41 PM Miguel Guerrero <<a href="mailto:g.miguel.guerrero.m@gmail.com" target="_blank">g.miguel.guerrero.m@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hello,<div>I hope this email finds you well.</div><div>First off, thanks for a great job implementing the PDAL for Python.</div><div>I have a LiDAR dataset in LAS format that has been pre-classified. I want to apply some filters to one or multiples classes. I followed the samples shown on <a href="https://pdal.io/stages/filters.html" target="_blank">https://pdal.io/stages/filters.html</a> and <a href="https://github.com/PDAL/python" target="_blank">https://github.com/PDAL/python</a>. I am able to get the filters to work but the final output only contains the classes 1 and/or 2, when in reality I would like to get the rest of the classes that were not used in the filtering process.</div><div>Any direction or suggestion would be greatly appreciated.</div><div><br></div><div>My best regards,</div><div><br></div><div>Miguel</div><div><br></div><div>Here is my code:</div><div><pre style="background-color:rgb(43,43,43);color:rgb(169,183,198);font-family:"JetBrains Mono";font-size:9.8pt"><span style="color:rgb(204,120,50)">import </span>os<br><br><span style="color:rgb(128,128,128)"># Input and validation of source directory<br></span><span style="color:rgb(204,120,50)">while True</span>:<br>    srcDirectory = os.path.normpath(<span style="color:rgb(136,136,198)">input</span>(<span style="color:rgb(106,135,89)">"Enter directory containing LAS files: "</span>))<br>    <span style="color:rgb(204,120,50)">if </span>os.path.exists(srcDirectory) <span style="color:rgb(204,120,50)">is True and </span>srcDirectory != <span style="color:rgb(106,135,89)">"."</span>:<br>        <span style="color:rgb(204,120,50)">break<br></span><span style="color:rgb(204,120,50)">    else</span>:<br>        <span style="color:rgb(136,136,198)">print</span>(srcDirectory<span style="color:rgb(204,120,50)">, </span><span style="color:rgb(106,135,89)">"is not a valid directory"</span>)<br><br><span style="color:rgb(128,128,128)"># Input and validation of destination directory<br></span><span style="color:rgb(204,120,50)">while True</span>:<br>    dstDirectory = os.path.normpath(<span style="color:rgb(136,136,198)">input</span>(<span style="color:rgb(106,135,89)">"Enter directory to store processed files: "</span>))<br>    <span style="color:rgb(204,120,50)">if </span>os.path.exists(dstDirectory) <span style="color:rgb(204,120,50)">is True and </span>dstDirectory != <span style="color:rgb(106,135,89)">"."</span>:<br>        <span style="color:rgb(204,120,50)">break<br></span><span style="color:rgb(204,120,50)">    else</span>:<br>        <span style="color:rgb(136,136,198)">print </span>(dstDirectory<span style="color:rgb(204,120,50)">, </span><span style="color:rgb(106,135,89)">"is not a valid directory"</span>)<br><br><span style="color:rgb(136,136,198)">print </span>(<span style="color:rgb(106,135,89)">""</span>)<br><br><span style="color:rgb(128,128,128)"># Change the working directory to the source directory<br></span>os.chdir(srcDirectory)<br><span style="color:rgb(136,136,198)">print </span>(<span style="color:rgb(106,135,89)">"Working directory is" </span>+ <span style="color:rgb(106,135,89)">" " </span>+ os.getcwd())<br><br><span style="color:rgb(128,128,128)"># Blank line for better visualization<br></span><span style="color:rgb(136,136,198)">print </span>(<span style="color:rgb(106,135,89)">""</span>)<br><br><span style="color:rgb(128,128,128)"># Create list of files in source directory<br></span>filesList = os.listdir(srcDirectory)<br><br><span style="color:rgb(204,120,50)">for </span>file <span style="color:rgb(204,120,50)">in </span>filesList:<br>    <span style="color:rgb(204,120,50)">if </span>file.endswith(<span style="color:rgb(106,135,89)">'las'</span>):<br>        fileIn = (srcDirectory + <span style="color:rgb(106,135,89)">"</span><span style="color:rgb(204,120,50)">\\</span><span style="color:rgb(106,135,89)">" </span>+ file).replace(<span style="color:rgb(106,135,89)">'</span><span style="color:rgb(204,120,50)">\\</span><span style="color:rgb(106,135,89)">'</span><span style="color:rgb(204,120,50)">, </span><span style="color:rgb(106,135,89)">'/'</span>)<br>        fileOut = (dstDirectory + <span style="color:rgb(106,135,89)">"</span><span style="color:rgb(204,120,50)">\\</span><span style="color:rgb(106,135,89)">" </span>+ file).replace(<span style="color:rgb(106,135,89)">'</span><span style="color:rgb(204,120,50)">\\</span><span style="color:rgb(106,135,89)">'</span><span style="color:rgb(204,120,50)">, </span><span style="color:rgb(106,135,89)">'/'</span>)<br><br>        json = <span style="color:rgb(106,135,89)">"""<br></span><span style="color:rgb(106,135,89)">            {<br></span><span style="color:rgb(106,135,89)">              "pipeline": [<br></span><span style="color:rgb(106,135,89)">                {<br></span><span style="color:rgb(106,135,89)">                    "type": "readers.las",<br></span><span style="color:rgb(106,135,89)">                    "filename": "%s"<br></span><span style="color:rgb(106,135,89)">                }<br></span><span style="color:rgb(106,135,89)">              ]<br></span><span style="color:rgb(106,135,89)">            }"""<br></span><span style="color:rgb(106,135,89)"><br></span><span style="color:rgb(106,135,89)">        </span><span style="color:rgb(204,120,50)">import </span>pdal<br>        <span style="color:rgb(204,120,50)">import </span>numpy <span style="color:rgb(204,120,50)">as </span>np<br>        pipeline = pdal.Pipeline(json % fileIn)<br>        count = pipeline.execute()<br><br>        arr = pipeline.arrays[<span style="color:rgb(104,151,187)">0</span>]<br>        <span style="color:rgb(136,136,198)">print</span>(<span style="color:rgb(136,136,198)">len</span>(arr))<br><br>        lasClass26 = arr[arr[<span style="color:rgb(106,135,89)">'Classification'</span>] == <span style="color:rgb(104,151,187)">26</span>]<br>        <span style="color:rgb(136,136,198)">print</span>(<span style="color:rgb(136,136,198)">len</span>(lasClass26))<br><br>        clamp = <span style="color:rgb(106,135,89)">u"""{<br></span><span style="color:rgb(106,135,89)">          "pipeline":[<br></span><span style="color:rgb(106,135,89)">            {<br></span><span style="color:rgb(106,135,89)">                "type":"filters.csf"                <br></span><span style="color:rgb(106,135,89)">            },<br></span><span style="color:rgb(106,135,89)">            {<br></span><span style="color:rgb(106,135,89)">                "type":"filters.range",<br></span><span style="color:rgb(106,135,89)">                "limits":"Classification[0:30]"<br></span><span style="color:rgb(106,135,89)">            },<br></span><span style="color:rgb(106,135,89)">            "%s"<br></span><span style="color:rgb(106,135,89)">          ]<br></span><span style="color:rgb(106,135,89)">        }""" </span>% (fileOut)<br><br>        p = pdal.Pipeline(clamp<span style="color:rgb(204,120,50)">, </span>[lasClass26])<br>        count = p.execute()<br>        clamped = p.arrays[<span style="color:rgb(104,151,187)">0</span>]<br>        <span style="color:rgb(136,136,198)">print</span>(count)</pre></div></div>
_______________________________________________<br>
pdal mailing list<br>
<a href="mailto:pdal@lists.osgeo.org" target="_blank">pdal@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/pdal" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/pdal</a></blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr">Andrew Bell<br><a href="mailto:andrew.bell.ia@gmail.com" target="_blank">andrew.bell.ia@gmail.com</a></div>
</blockquote></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature">Andrew Bell<br><a href="mailto:andrew.bell.ia@gmail.com" target="_blank">andrew.bell.ia@gmail.com</a></div></div></div></div>