I am trying to generate a normalized height values for a catalog of las tiles. I first generated a dtm using:
dtm = grid_terrain(ctg, knnidw(k=5))
Then, I normalize the values using:
normalized = lasnormalize(ctg, dtm)
The normalized data set shows some negative values, however they happen to be wildly large. I'm wondering what I might be doing that could cause this to happen. Here is some more info on the data I'm using:
> head(data.table(ctg@data)[, .(Min.Z)][order(Min.Z)]) Min.Z 1: 396.91 2: 430.77 3: 456.20 4: 456.51 5: 458.07 6: 463.13 > dtm@data@max  753.7401 > head(data.table(normalized@data)[, .(Min.Z)][order(Min.Z)]) Min.Z 1: -21474836.48 2: -21474836.48 3: -183.38 4: -171.77 5: -19.05 6: -17.92
Given the largest value in the dtm, I don't see how -21474836.48 could possibly be generated.
ctg is my catalog of las files.
dtm is the raster generated from
normalized is the result of
It turns out that none of the individual chunked/tiled .tif rasters have negative values. The
grid_terrain.vrt file produced by
grid_terrain has several huge negative values (looks like it might be the most negative number possible). Here is a summary of
vrt class : RasterLayer dimensions : 24000, 3000, 72000000 (nrow, ncol, ncell) resolution : 1, 1 (x, y) extent : 535500, 538500, 4872000, 4896000 (xmin, xmax, ymin, ymax) crs : +proj=utm +zone=18 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs source : memory names : grid_terrain values : -339999999999999996123846586046231871488, 753.7401 (min, max)
It looks like there are plenty of these too:
> length(vrt@data@values[vrt@data@values < 0])  21606964 > unique(vrt@data@values[vrt@data@values < 0])  -339999999999999996123846586046231871488
So a better set of questions:
Should I be using
grid_terrain.vrt as my dtm for normalization?
If so, why could there be so many of these huge negatives in
If not, how should I be using the output of
grid_terrain() to normalize my las files?