chm_zd_bckup.py
def dem_extract(lidar_fn, out_fn, stat, in_srs="EPSG:2180", out_srs="EPSG:2178"):
    """Creating DSM and DTM (both trees only) from lidar data"""
    start = time.time()
    elevation = "DTM" if stat == "min" else "DSM"
    print("{} extracting...".format(elevation))

    pdal_json = {
        "pipeline": [
            "{}".format(lidar_fn),
            {
                "type": "filters.reprojection",
                "in_srs": "{}".format(in_srs),
                "out_srs": "{}".format(out_srs)
            },
            {
                "type": "filters.hag_nn",
            },
            {
                "type": "filters.range",
                "limits": "Classification[5:5]",
            },
            {
                "filename": "{}\{}_{}.tif".format(out_fn, elevation, os.path.basename(lidar_fn)[:-4]),
                "gdaldriver": "GTiff",
                "output_type": "{}".format(stat),
                "resolution": "1",
                "type": "writers.gdal"
            }
        ]
    }

    pdal_json_str = json.dumps(pdal_json)
    pipeline = pdal.Pipeline(pdal_json_str)
    pipeline.execute()
    end = time.time()

    print("{} extracted successfully in {:.2f} sec\n".format(elevation, end - start))
Creating DSM and DTM (both trees only) from lidar data
Creating DSM and DTM (both trees only) from lidar data
Creating DSM and DTM ( both trees only ) from lidar data
def dem_extract(lidar_fn, out_fn, stat, in_srs="EPSG:2180", out_srs="EPSG:2178"):
    start = time.time()
    elevation = "DTM" if stat == "min" else "DSM"
    print("{} extracting...".format(elevation))
    pdal_json = {
        "pipeline": [
            "{}".format(lidar_fn),
            {
                "type": "filters.reprojection",
                "in_srs": "{}".format(in_srs),
                "out_srs": "{}".format(out_srs)
            },
            {
                "type": "filters.hag_nn",
            },
            {
                "type": "filters.range",
                "limits": "Classification[5:5]",
            },
            {
                "filename": "{}\{}_{}.tif".format(out_fn, elevation, os.path.basename(lidar_fn)[:-4]),
                "gdaldriver": "GTiff",
                "output_type": "{}".format(stat),
                "resolution": "1",
                "type": "writers.gdal"
            }
        ]
    }
    pdal_json_str = json.dumps(pdal_json)
    pipeline = pdal.Pipeline(pdal_json_str)
    pipeline.execute()
    end = time.time()
    print("{} extracted successfully in {:.2f} sec\n".format(elevation, end - start))
def dem_extract ( lidar_fn , out_fn , stat , in_srs = "EPSG:2180" , out_srs = "EPSG:2178" ) : start = time . time ( ) elevation = "DTM" if stat == "min" else "DSM" print ( "{} extracting..." . format ( elevation ) ) pdal_json = { "pipeline" : [ "{}" . format ( lidar_fn ) , { "type" : "filters.reprojection" , "in_srs" : "{}" . format ( in_srs ) , "out_srs" : "{}" . format ( out_srs ) } , { "type" : "filters.hag_nn" , } , { "type" : "filters.range" , "limits" : "Classification[5:5]" , } , { "filename" : "{}\{}_{}.tif" . format ( out_fn , elevation , os . path . basename ( lidar_fn ) [ : - 4 ] ) , "gdaldriver" : "GTiff" , "output_type" : "{}" . format ( stat ) , "resolution" : "1" , "type" : "writers.gdal" } ] } pdal_json_str = json . dumps ( pdal_json ) pipeline = pdal . Pipeline ( pdal_json_str ) pipeline . execute ( ) end = time . time ( ) print ( "{} extracted successfully in {:.2f} sec\n" . format ( elevation , end - start ) )
Creating DSM and DTM (both trees only) from lidar data
Creating DSM and DTM ( both trees only ) from lidar data
"""Creating DSM and DTM (both trees only) from lidar data"""
lidar_fn
out_fn
stat
in_srs
out_srs