[R-sig-Geo] LiDAR LAS file import into R via RSAGA

Clay S clayms at gmail.com
Fri Feb 12 07:51:49 CET 2016


Thanks Michael Sumner

rLidar works well.  But how do I pass the lidar data to another SAGA module
within R without saving the output of each step as a file in a whole series
of SAGA module calls from R?

I would like something like the dplyr %>% pipe command.

Thanks
Clay

On Fri, Feb 12, 2016 at 7:44 PM, Michael Sumner <mdsumner at gmail.com> wrote:

> Try rLidar::readLAS as a straightforward alternative, it's not bullet
> proof but works fine for a lot of examples. Happy to help extend it if your
> format is not supported.
>
> Cheers, Mike
>
> On Fri, 12 Feb 2016 7:41 am 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
>>
> --
> Dr. Michael Sumner
> Software and Database Engineer
> Australian Antarctic Division
> 203 Channel Highway
> Kingston Tasmania 7050 Australia
>
>

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list