# Comparison of lidar dems

We patch lidar data on to ASTER data during delivery creation and need to know how accurately that data has been patched and, if it is differing, to what level it differs.

To do this we can use:

```demcompare.py -d lidarpatched.dem -n navfile.sol --lidar path/to/ascii -l projection
```

Unless you have an SSD available in your machine this will probably take a while.

This will create a patched aster dem to compare to the lidar dem, this will not be smoothed and as such is the raw ASTER data. It will give 2 outputs on completion the first is only the area covered by the lidar files, the second is the entire dem. All outputs are in metres.

```Temp folder created at:/tmp/grassdb-24688-115643
Calculation performed:GB13_10_2014_156_lidar_ASTER_bng.dem-ASTER_tiles.dem
The maps were compared in:WGS84LL
GB13_10_2014_156_lidar_ASTER_bng.dem was imported in:UKBNG
ASTER_tiles.dem sum	:1420384.824150

GB13_10_2014_156_lidar_ASTER_bng.dem sum	:1444242.484528

Comparison sum	:-23857.657357

Difference statistics:
Min:		-69.939673828125
Max:		32.3908696899414
Sum:		-23857.6575275853
Mean:		-1.8243983732955
Median:		-0.985404
Absolute mean:	5.99935342521819
Std deviation:	8.54745020068044
Total cells:	39672
Non-null cells:	13077

Min:		-69.939673828125 - The minimum height measurement in the dem
Max:		32.3908696899414 - The maximum height measurement in the dem
Sum:		-24706.5998933041 - Total of all heights in the dem
Mean:		-0.641529909984007 - Mean height
Median:		5.49316e-07 - Median height
Absolute mean:	2.21956360209108 - Mean based on only absolute values
Std deviation:	5.18281446074588 - std deviation of height
Total cells:	39672 - number of cells
Non-null cells:	38512 - number of cells with height measurements
```

Preferably the mean (non-absolute) for the lidar area would be around 0 metres, but in practice it tends to be around 2 to 4 metres for UK data and varying for UTM data.

You can compare 2 dems already created using

```demcompare.py -d dem1.dem -c dem2.dem --lidar /if/needed
```

Which will skip the patching process and just give the dem outputs, if you use identical dems the outputs will be 0.

### errors in processing

If something goes wrong during processing first, check in grass that the files needed exist. (open grass and run g.list)

After this check dems you are comparing overlap, and lidar data you are using is within the bounds of the dem(s).

### Non standard outputs

There are a few other options for deeper analysis of dems, and analysis of trends over years

```--output OUTPUT       output the resultant comparison DEM for inspection in
another program.
```

Use this to inspect the created dem and comparison dem in envi, you can confirm figures from these.

```--histogram HISTOGRAM
Create a histogram and output it as a png at specified
location. Include file extension.
--png PNG               Create a PNG of the difference dem at the specified
location. Include file extension.
```

The histogram option provides a better visualisation of the mean data. PNG can be used to provide quick looks at a heatmap of the data for comparison.

### Batch processing

```  --csv                 Output as csv format for batch processing.
--script              Use with csv to indicate return rather than print
```

Use these two for batch processing, can be useful for creating profiles of whole years worth of data. These would be helpful if we wanted to see our overall accuracy over the year.