[pdal] PDAL Python working with an specific dimension (classification)

Miguel Guerrero g.miguel.guerrero.m at gmail.com
Thu May 14 15:50:38 PDT 2020


Thanks for the prompt reply!
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?
Example:
UserData = 0 => Classification = class 16
UserData = 1 => Classification = class 17

Thanks in advance for your help

Miguel

On Thu, May 14, 2020 at 1:01 PM Andrew Bell <andrew.bell.ia at gmail.com>
wrote:

> filters.csf is a ground filter, so it classifies everything as either
> ground or unclassified.
>
> On Thu, May 14, 2020 at 3:41 PM Miguel Guerrero <
> g.miguel.guerrero.m at gmail.com> wrote:
>
>> Hello,
>> I hope this email finds you well.
>> First off, thanks for a great job implementing the PDAL for Python.
>> 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 https://pdal.io/stages/filters.html and
>> https://github.com/PDAL/python. 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.
>> Any direction or suggestion would be greatly appreciated.
>>
>> My best regards,
>>
>> Miguel
>>
>> Here is my code:
>>
>> import os
>>
>> # Input and validation of source directory
>> while True:
>>     srcDirectory = os.path.normpath(input("Enter directory containing LAS files: "))
>>     if os.path.exists(srcDirectory) is True and srcDirectory != ".":
>>         break
>>     else:
>>         print(srcDirectory, "is not a valid directory")
>>
>> # Input and validation of destination directory
>> while True:
>>     dstDirectory = os.path.normpath(input("Enter directory to store processed files: "))
>>     if os.path.exists(dstDirectory) is True and dstDirectory != ".":
>>         break
>>     else:
>>         print (dstDirectory, "is not a valid directory")
>>
>> print ("")
>>
>> # Change the working directory to the source directory
>> os.chdir(srcDirectory)
>> print ("Working directory is" + " " + os.getcwd())
>>
>> # Blank line for better visualization
>> print ("")
>>
>> # Create list of files in source directory
>> filesList = os.listdir(srcDirectory)
>>
>> for file in filesList:
>>     if file.endswith('las'):
>>         fileIn = (srcDirectory + "\\" + file).replace('\\', '/')
>>         fileOut = (dstDirectory + "\\" + file).replace('\\', '/')
>>
>>         json = """
>>             {
>>               "pipeline": [
>>                 {
>>                     "type": "readers.las",
>>                     "filename": "%s"
>>                 }
>>               ]
>>             }"""
>>
>>         import pdal
>>         import numpy as np
>>         pipeline = pdal.Pipeline(json % fileIn)
>>         count = pipeline.execute()
>>
>>         arr = pipeline.arrays[0]
>>         print(len(arr))
>>
>>         lasClass26 = arr[arr['Classification'] == 26]
>>         print(len(lasClass26))
>>
>>         clamp = u"""{
>>           "pipeline":[
>>             {
>>                 "type":"filters.csf"
>>             },
>>             {
>>                 "type":"filters.range",
>>                 "limits":"Classification[0:30]"
>>             },
>>             "%s"
>>           ]
>>         }""" % (fileOut)
>>
>>         p = pdal.Pipeline(clamp, [lasClass26])
>>         count = p.execute()
>>         clamped = p.arrays[0]
>>         print(count)
>>
>> _______________________________________________
>> pdal mailing list
>> pdal at lists.osgeo.org
>> https://lists.osgeo.org/mailman/listinfo/pdal
>
>
>
> --
> Andrew Bell
> andrew.bell.ia at gmail.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/pdal/attachments/20200514/0142cde1/attachment-0001.html>


More information about the pdal mailing list