python-pdal

2023-08-03  本文已影响0人  hehehehe
In [1]: import pdal
   ...: import numpy as np
   ...: import matplotlib.pyplot as plt
In [13]: pipeline = {
    ...:     "pipeline": [
    ...:         {
    ...:             "type": "readers.las",
    ...:             "filename": "/Users/shilulu/Downloads/sample.laz"
    ...:         },
    ...:         {
    ...:             "type": "writers.pcd",
    ...:             "filename": "/Users/shilulu/Downloads/sample.pcd"
    ...:         }
    ...:     ]
    ...: }
In [14]: pipeline = pdal.Pipeline(json.dumps(pipeline))
    ...: 

In [15]: pipeline.execute()
Out[15]: 150395
{
  "pipeline":[
    {
      "type":"readers.las",
      "filename":"input.las"
    },
    {
      "type":"filters.reprojection",
      "in_srs":"EPSG:4326",
      "out_srs":"EPSG:3857"
    },
    {
      "type":"writers.las",
      "filename":"output.las"
    }
  ]
}

{
  "pipeline": [
    {
      "type": "readers.las",
      "filename": "input.las"
    },
    {
      "type": "filters.assign",
      "assignment": "X=(X*5)"
    },
    {
      "type": "writers.las",
      "filename": "output.las"
    }
  ]
}

import numpy as np
from pdal import pipeline

def multiply_x(arr: np.ndarray, factor: float) -> np.ndarray:
    arr['X'] *= factor
    return arr

json = """
{
  "pipeline": [
    {
      "type": "readers.las",
      "filename": "input.las"
    },
    {
      "type": "filters.python",
      "function": "multiply_x",
      "module": "your_module",
      "add_dimension": "X",
      "pdalargs": {
        "factor": 5
      }
    },
    {
      "type": "writers.las",
      "filename": "output.las"
    }
  ]
}
"""

pipeline = pdal.Pipeline(json)
pipeline.execute()

上一篇 下一篇

猜你喜欢

热点阅读