[R-sig-Geo] LiDAR LAS file import into R via RSAGA
Michael Treglia
mtreglia at gmail.com
Fri Feb 12 00:26:25 CET 2016
Hi Clay,
At some point I was looking into something similar, and don't think you can
do that with RSAGA. rsaga.geoprocessor() is running things as a system
commands (like running from the command line directly), so it is not
bringing the Lidar data into R, if I recall correctly.
One package you might want to look into is rLidar:
https://cran.r-project.org/web/packages/rLiDAR/index.html - it has some
good functionality for importing data (they get imported as a matrix which
can then be processed in various ways), visualization, and processing,
largely in a forestry context.
Hope that helps,
Mike
On Thu, Feb 11, 2016 at 2:40 PM, Clay S <clayms at gmail.com> wrote:
> Hi
>
> Is it possible to import a Lidar LAS file into R with the
> rsaga.geoprocessor function of the RSAGA package. The following code runs
> without an error, but all I get in R is the SAGA console output.
>
> The R code below does save a SAGA point cloud file called "test" in my
> working directory. If I delete the `POINTS = "test"` parameter, then
> nothing happens as expected. However, I want to work with the data in R,
> and pass the point cloud to other SAGA modules. This can be done in SAGA
> without having to save the point cloud. Can the same be done from R?
>
> How can I get the point cloud imported into the R environment? Do I need
> to coerce it into a matrix, data frame, or Spatial Points object?
>
>
> R code:
>
> ###############
>
> library(RSAGA)
>
>
> # Set RSAGA environment.
>
> env <- rsaga.env()
>
>
> # SET WORKING DIRECTORY FIRST!!
>
> dir <- getwd()
>
>
> # Get module parameters
>
> lasfilelist <- list.files(dir, pattern =".las$", full.names=TRUE,
> recursive=FALSE)
>
>
> # send command to RSAGA
>
> test <- rsaga.geoprocessor(lib = "io_shapes_las", module = "Import LAS
> Files",
> param = list(FILES = lasfilelist[1], POINTS = "test",
> T=TRUE, i=TRUE, a=FALSE, r=TRUE, c=FALSE,
> u=FALSE,
> n=TRUE, R=FALSE, G=FALSE, B=FALSE, e=FALSE,
> d=FALSE,
> p=FALSE, C=FALSE, VALID=FALSE,
> RGB_RANGE=FALSE),
> env = env)
>
> ###################
>
>
> Here is the console output (the test variable stores the same thing):
>
> ###########
>
> library path: C:\OSGEO4~1\apps\saga\modules\io_shapes_las.dll
> library name: Import/Export - LAS
> tool name : Import LAS Files
> author : O. Conrad, V. Wichmann (c) 2009
>
> Parameters
>
> Input Files: "C:/Users/whcms0/'.CPT/Tarewa/Lidar/AX300711.las"
> Point Clouds: No objects
> gps-time: yes
> intensity: yes
> scan angle: no
> number of the return: yes
> classification: no
> user data: no
> number of returns of given pulse: yes
> red channel color: no
> green channel color: no
> blue channel color: no
> edge of flight line flag: no
> direction of scan flag: no
> point source ID: no
> rgb color: no
> Check Point Validity: no
> R,G,B value range: 16 bit
>
> Parsing AX300711.las ...
> Save point cloud: test...
>
> ################
>
>
> Here is my env:
>
> ################
>
> > env
>
> $workspace
>
> [1] "."
>
>
> $cmd
>
> [1] "saga_cmd.exe"
>
>
> $path
>
> [1] "C:\\OSGeo4W64\\apps\\saga"
>
>
> $modules
>
> [1] "C:\\OSGeo4W64\\apps\\saga/modules"
>
>
> $version
>
> [1] "2.1.2"
>
>
> $cores
>
> [1] NA
>
>
> $parallel
>
> [1] FALSE
>
>
> $lib.prefix
>
> [1] ""
>
> #################
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
[[alternative HTML version deleted]]
More information about the R-sig-Geo
mailing list