This can be done with a [tag:PDAL]  [filter][1] using either _Simple Morphological Filter (SMRF)_ or _Progressive Morphological Filter (PMF)_ algorithms.

### Quick

    pdal ground --cell_size=5 --extract input.laz out-bare-earth.laz

Creates a bare earth compressed LAS file with a 5 ground unit cell size using PMF. ([docs][3])

For more explanation see the [Identifying ground returns using ProgressiveMorphologicalFilter segmentation][2] tutorial.

### More involved, using SMRF

A [pipeline][4] example that:

- applies the SMRF filter, enlarges the `cell` size option to 2.0 (coordinate system units) and a 0.75 threshold
- selects only the newly classified ground points (`2` is the LAS standard value for ground)
- writes selection to an uncompressed LAS output file (just change extension to .laz for compressed)

Command: `pdal pipeline "classify-ground-smrf.json"`

The JSON parameters file:

    {
        "pipeline": [
            "inputfile.laz",
        {
          "type":"filters.smrf",
          "cell": "2.0",
          "threshold": "0.75"
        },
        {
          "type":"filters.range",
          "limits":"Classification[2:2]"
        },
        "out/smurf_classifed.las"
        ]
    }

### Extract above ground only

This example a) classifies into ground/not-ground, b) adds "Height Above Ground" attribute, and c) exports only above ground points.

    {"pipeline": [
        "input.laz",
        {"type": "filters.assign",
           "assignment": "Classification[:]=0"},
        {"type": "filters.smrf"},
        {"type": "filters.hag"},
        {"type": "filters.range",
           "limits": "HeightAboveGround[2:]"},
        {"type": "filters.approximatecoplanar",
           "knn": 10},
        {"type": "filters.range",
           "limits": "Coplanar[1:1]"},
        {"filename":"above-ground.laz"}
    ]}

_Adapted from Bruce Chambers, https://lists.osgeo.org/pipermail/pdal/2017-July/001367.html_

  [1]: https://www.pdal.io/stages/filters.html
  [2]: https://www.pdal.io/tutorial/pcl_ground/index.html
  [3]: https://www.pdal.io/apps/ground.html
  [4]: https://www.pdal.io/pipeline.html
  [5]: https://gist.github.com/maphew/652c5cb51516e9d1f1c88cd3ec634289