# Rasterizing Attributes¶

This exercise uses PDAL to generate a raster surface using a fully classified point cloud with PDAL’s writers.gdal.

## Exercise¶

Note

The exercise fetches its data from a Greyhound service that organizes the point cloud collection for the entire country of Denmark. You can view the data online at http://potree.entwine.io/data/denmark.html

### Command¶

Invoke the following command, substituting accordingly, in your OSGeo4W Shell:

PDAL capability to generate rasterized output is provided by the writers.gdal stage. There is no application to drive this stage, and we must use a pipeline.

### Pipeline breakdown¶

Note

This pipeline is available in your workshop materials in the ./exercises/analysis/dtm/dtm.json file. Make sure to edit the filenames to match your paths.

    {
},
{


The data is read from a readers.greyhound server that hosts the Denmark data. We’re going to download a small patch of data by the Copenhagen airport that is the “full depth” of the tree.

#### 2. writers.gdal¶

The writers.gdal writer that bins the point cloud data with classification values.

    {
"type":"writers.gdal",
"filename":"denmark-classification.tif",
"dimension":"Classification",
"data_type":"uint16_t",
"output_type":"mean",
"resolution":30.0
}


### Execution¶

Issue the pipeline operation to execute the interpolation:

pdal pipeline classification.json

{
"pipeline":[
{
},
{
"type":"writers.gdal",
"filename":"denmark-classification.tif",
"dimension":"Classification",
"data_type":"uint16_t",
"output_type":"mean",
"resolution":30.0
}
]
}


### Visualization¶

Unfortunately, this doesn’t give us a very satisfactory image to view. The reason is there is no color ramp associated with the file, and we’re looking at pixel values with values from 0-31 according to the ASPRS LAS specification.

We want colors that correspond to the classification values a bit more directly. We can use a color ramp to assign explicit values. QGIS allows us to create a text file color ramp that gdaldem can consume to apply colors to the data.

  1 2 3 4 5 6 7 8 9 10 11 12 # QGIS Generated Color Map Export File 0,255,0,0,255 1,234,234,234,255 2,222,126,44,255 3,30,62,15,255 4,45,255,6,255 5,209,230,201,255 6,249,12,6,255 7,146,197,222,255 8,133,5,2,255 9,0,0,255,255 10,255,255,255,255 

With the ramp, we can use gdaldem to apply it to a new image:

 1 2 3 4 5 6 gdaldem color-relief ^ denmark-classification.tif ^ ramp.txt ^ classified-color.png ^ -exact_color_entry ^ -of PNG 

#### Intensity¶

With PDAL’s ability to override pipeline via commands, we can generate a relative intensity image:

 1 2 3 4 5 6 pdal pipeline classification.json ^ --writers.gdal.dimension="Intensity" ^ --writers.gdal.data_type="float" ^ --writers.gdal.filename="intensity.tif" gdal_translate intensity.tif intensity.png -of PNG 

## Notes¶

1. writers.gdal can output any dimension PDAL can provide, but it is is up to the user to interpolate the values. For categorical data, neighborhood smoothing might produce undesirable results, for example.