美文网首页
python-pdal

python-pdal

作者: hehehehe | 来源:发表于2023-08-03 14:26 被阅读0次
    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()
    
    

    相关文章

      网友评论

          本文标题:python-pdal

          本文链接:https://www.haomeiwen.com/subject/ldumpdtx.html