manaakiwhenua / pycrown

PyCrown - Fast raster-based individual tree segmentation for LiDAR data
https://datastore.landcareresearch.co.nz/dataset/pycrown
GNU General Public License v3.0
178 stars 68 forks source link

How can I generate DEM DTM and CHM from point cloud #18

Open nefuhhanrui opened 3 years ago

nefuhhanrui commented 3 years ago

i hava point cloud data in .las format and then how can I generate DEM DTM and CHM from point cloud? Can someone tell me? Thank you very much

smallpondtom commented 3 years ago

@nefuhhanrui Hi, this might be too late but what I did was use PDAL with python to generate a DSM and DTM, and then I used gdal_calc.py which comes with GDAL to take the difference between the DSM and DTM to generate a CHM.

I hope this answers your question.

AmmarOkran commented 3 years ago

Hi I have las file, and I need to apply your algorithm but I need to generate the DSM and DTM, I used pdal as you mentioned but the result is different. I thought maybe the problem from my dataset but also the same with your las file. Could you pass the pipeline that you used to generate the DSM and DTM TIF files

AmmarOkran commented 3 years ago

@smallpondtom @zjans

I have taken your file POINTS.las to generate DEM, DSM, and CHM but what I got totally different for yours and when I applied Pycrown it gave me an exception: File "fiona/ogrext.pyx", line 1285, in fiona.ogrext.WritingSession.writerecs fiona.errors.GeometryTypeValidationError: Record's geometry type does not match collection schema's geometry type: 'LineString' != 'Polygon'

The pipeline for DTM as follows:

creating_json = {
            "pipeline": [
            {
                "type": "readers.las",
                "filename": f"{lasfile}",
                "spatialreference": "EPSG:2193"
            },
            {
                "type":"filters.assign",
                "assignment":"Classification[:]=0"
            },
            {
                "type":"filters.elm"
            },
            {
                "type":"filters.outlier",
                "method":"statistical",
                "mean_k":8,
                "multiplier":3.0
            },
            {
                "type":"filters.smrf",
                "ignore":"Classification[7:7]",
                "slope":.15,
                "window":18,
                "threshold":0.30,
                "scalar":0.95
            },
            {
                "type":"filters.range",
                "limits":"Classification[2:2]"
            },
            {
                "type": "writers.gdal",
                "filename": f"{outputfile}",
                "output_type": "idw",
                "gdaldriver": "GTiff",
                "resolution": f"{resolution}", 
                "nodata":"-9999",
                "radius": 1,
                "data_type": "float32"
            }

            ]
    }

The pipeline for DSM as follows:

creating_json = {
            "pipeline": [
            {
                "type": "readers.las",
                "filename": f"{lasfile}",
                "spatialreference": "EPSG:2193"
            },
            {
                "type": "filters.range",
                "limits":"returnnumber[1:1]"
            },
            {
                "type": "writers.gdal",
                "filename": f"{outputfile}",
                "output_type": "idw",
                "gdaldriver": "GTiff",
                "resolution": f"{resolution}", 
                "nodata":"-9999",
                "radius":1,
                "data_type": "float32"
            }

            ]
    }

Any suggestion!