chm_zd.py
def extract_dsm(lidar_fn, out_fn, stat, in_srs="EPSG:2180", out_srs="EPSG:2178"):
    """the first assumption of the function was to calculate the results for both
    DSM and DTM (only in trees areas) from lidar data. Due to complication with
    DTM (the height was overstated by about 5m) right now it's used only for
    calculating DSM. The "stat" parameter was originally needed to differentiate
    between both layers"""

    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 = {
        "pipeline": [
            "{}".format(lidar_fn),
            {
                "type": "filters.reprojection",
                "in_srs": "{}".format(in_srs),
                "out_srs": "{}".format(out_srs)
            },
            {
                "type": "filters.range",
                "limits": "returnnumber[1:1]"
            },
            {
                "type": "filters.range",
                "limits": "Classification[5:5]",
            },
            {
                "type": "writers.gdal",
                "filename": "{}\{}_{}.tif".format(out_fn, elevation, os.path.basename(lidar_fn)[:-4]),
                "output_type": "{}".format(stat),
                "gdaldriver": "GTiff",
                "resolution": 1,
                "radius": 1

            }
        ]
    }

    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))
the first assumption of the function was to calculate the results for both
    DSM and DTM (only in trees areas) from lidar data. Due to complication with
    DTM (the height was overstated by about 5m) right now it's used only for
    calculating DSM. The "stat" parameter was originally needed to differentiate
    between both layers
the first assumption of the function was to calculate the results for both
DSM and DTM (only in trees areas) from lidar data. Due to complication with
DTM (the height was overstated by about 5m) right now it's used only for
calculating DSM. The "stat" parameter was originally needed to differentiate
between both layers
the first assumption of the function was to calculate the results for both DSM and DTM ( only in trees areas ) from lidar data . Due to complication with DTM ( the height was overstated by about 5m ) right now it ' s used only for calculating DSM . The " stat " parameter was originally needed to differentiate between both layers
def extract_dsm(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.range",
                "limits": "returnnumber[1:1]"
            },
            {
                "type": "filters.range",
                "limits": "Classification[5:5]",
            },
            {
                "type": "writers.gdal",
                "filename": "{}\{}_{}.tif".format(out_fn, elevation, os.path.basename(lidar_fn)[:-4]),
                "output_type": "{}".format(stat),
                "gdaldriver": "GTiff",
                "resolution": 1,
                "radius": 1
            }
        ]
    }
    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 extract_dsm ( 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.range" , "limits" : "returnnumber[1:1]" } , { "type" : "filters.range" , "limits" : "Classification[5:5]" , } , { "type" : "writers.gdal" , "filename" : "{}\{}_{}.tif" . format ( out_fn , elevation , os . path . basename ( lidar_fn ) [ : - 4 ] ) , "output_type" : "{}" . format ( stat ) , "gdaldriver" : "GTiff" , "resolution" : 1 , "radius" : 1 } ] } 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 ) )
the first assumption of the function was to calculate the results for both
DSM and DTM (only in trees areas) from lidar data.
the first assumption of the function was to calculate the results for both DSM and DTM ( only in trees areas ) from lidar data .
"""the first assumption of the function was to calculate the results for both
    DSM and DTM (only in trees areas) from lidar data. Due to complication with
    DTM (the height was overstated by about 5m) right now it's used only for
    calculating DSM. The "stat" parameter was originally needed to differentiate
    between both layers""" # 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"
 #         }
 #     ]
 # }

lidar_fn
out_fn
stat
in_srs
out_srs