LAScatalog with user-defined grid #538
Replies: 9 comments 2 replies
-
Do you mean providing a simple way to generate chunks that are always aligned the same independently of the collection? It is already the case. It is not easy to verify but below is a reproducible example that demonstrate the grid is common to both collections
|
Beta Was this translation helpful? Give feedback.
-
Let's say I calculated metrics from RGB images according to a given raster with res=1m. Then, I want to calculate metrics from a las point cloud using
How can I ensure that both output rasters overlap? Does the output raster depend on the way I define the chunks? |
Beta Was this translation helpful? Give feedback.
-
with
Absolutely not. |
Beta Was this translation helpful? Give feedback.
-
You are not the first one to ask similar question. See also https://gis.stackexchange.com/questions/418332/change-extent-of-lidr-las-object-for-raster-alignment In short: it just work the way you want it to work. You don't need to think too much about it. |
Beta Was this translation helpful? Give feedback.
-
@Jean-Romain I try it but the output raster (origin and extent) does not match the template (origin and extent). work.dir<-".../lasFolder/"
ctg <- readLAScatalog(work.dir)
r <- raster(".../Large_ClassifiedPC_chm_20m.tif")
print(ncell(r))
#> [1] 50370
fg<-grid_metrics(ctg, ~mean(Z), res=r)
#> Processing [===========================================================================================================] 100% (4/4) eta: 0s
print(ncell(fg))
#> [1] 2500
writeRaster(fg,".../Large_ClassifiedPC_chm_20m_resampled4.tif") |
Beta Was this translation helpful? Give feedback.
-
I'm not excluding the existence of a bug but I'm more confident on the fact that it behaves as expected but not necessarily as you were expecting. The output Please show plot(ctg)
plot(r, add = T) |
Beta Was this translation helpful? Give feedback.
-
Yes, r is much larger than ctg. I confirm that the cells of r and fg are aligned. So, one solution might be to resample fg cells into r using a nearest neighbor approach. |
Beta Was this translation helpful? Give feedback.
-
Why do you want to resample |
Beta Was this translation helpful? Give feedback.
-
I think it would be interesting to provide a pre-defined grid cell (raster file) that would be constant independently of the LAS files. It would be useful, for instance, to resample different datasets into a common grid.
Beta Was this translation helpful? Give feedback.
All reactions