Search code examples
pythonpoint-clouds

What is the syntax for pdalargs in filters.programmable in PDAL in Python?


I'm using pdal with python, and I am trying to use the programmable filter. According to the documenation I should be able to parse additional input arguments to my python function by writing (page 141)

{
    "pipeline":[
        "input.las",
        {
            "type":"filters.programmable",
            "module":"anything",
            "function":"filter",
            "source":"arguments.py",
            "pdalargs":"{\"factor\":0.3048,\"an_argument\":42, \"another\": \"a string\"}"
        },
        "output.las"
    ]
}

I tried copy-pasting EXACTLY this (really, I only changed the name of the input las-file), and I keep getting this error:

RuntimeError: JSON pipeline: Unable to parse pipeline:
* Line 13, Column 15
  Missing ',' or '}' in object declaration

I tried randomly removing and inserting " and \ in the pdalargs argument, but I can't seem to get the syntax right. (it works fine without pdalargs)

Is there an update or something that is not in the documentation?? How is the syntax actually supposed to be to use pdalargs??


Solution

  • I found out how to change the syntax. The problem may have occurred because I am writing the json code as a string in the python script.

    Anyway, this syntax seems to work:

    jsonStr = """{
        "pipeline":[
            "input.las",
            {
                "type":"filters.programmable",
                "module":"anything",
                "function":"filter",
                "source":"arguments.py",
                "pdalargs": {"factor":0.3048,"an_argument":42, "another": "a string"}
            },
            "output.las"
        ]
    }"""
    

    Hope this helps if anyone else has the same problem.