Skip to content
Prev 8433 / 29559 Next

read function for LAS data

Hello,
That was certainly true of the version of code I posted, but writing a
more flexible version is not difficult, and actually less difficult
than I expected. I've implemented arguments to "skip" and read "nrows"
at a time, so there is the beginnings of a wrapper around the core
read for building more flexibility.

(I was thinking of including subsetting of various kinds which really
makes it more complicated, and the appropriate level to handle that is
in a wrapper to this function).

I've updated the R source on my site, and here's a new example. This
should be considered as a rough working draft, the details can be
hidden in the final suite of functions. My chunk/rows handling is
pretty awkward, and may have bugs for particular record numbers.

Any testing you can provide would be greatly appreciated.


# new version with "skip" and "nrows" arguments
source("http://staff.acecrc.org.au/~mdsumner/las/readLAS.R")

f <- "lfile.las"

## get just the header
hd <- readLAS(f, returnHeaderOnly = TRUE)

numrows <- hd$`Number of point records`
## [1] 1922632

## read in chunks, and pass to DB or ff, or subset by sampling, etc..
rowskip <- 0
chunk <- 1e5
rowsleft <- numrows

system.time({

## keep track of how many rows we skip, and how many are left
for (i in 1:ceiling(numrows / chunk)) {
	if (rowsleft < chunk) chunk <- rowsleft
	if (chunk < 1) break;
	d <- readLAS(f, skip = rowskip, nrows = chunk)
	rowskip <- rowskip + nn
	rowsleft <- numrows - nn
}

})

#   user  system elapsed
#   1.10    0.55    1.64







On Sun, Jun 6, 2010 at 8:09 PM, Etienne Bellemare Racine
<etiennebr at gmail.com> wrote: