Closed Kodiologist closed 3 months ago
The problem appears to be in lidR
, please raise there. Please also provide a regular script, not using Rscript.
I don't know what a "regular script" is, but the above is from using the normal R binary, not Rscript.
To be run in interactive R at the R prompt. There are no "rgrass guys", there is one retired academic.
That would need some way to reset the state of all packages (I think) which isn't fully implemented (I think).
Why do you need to run the pointless lidR
code prior to the rgrass
code?
Loading lidR seems to be necessary to reproduce the bug. The original code in which I encountered this bug uses lidR nontrivially. I changed it to a trivial use here to make the example minimal.
Provide a minimal example actually doing something. Could you create the GRASS location first, then use lidR
?
To be clear, I don't expect you to find a workaround for me. I already have one, which is to say library(terra)
. I just filed a bug report because I thought it might be useful.
Could you create the GRASS location first, then use
lidR
?
Maybe? The trick is that I'm creating the location using a raster that's generated by lidR.
Provide a minimal example actually doing something.
Here's a little incomplete script I've been working on. It doesn't do anything useful yet. The idea is to use GRASS's r.sun
to map sun exposure at the nursing homes.
library(sf)
library(terra)
grass.path = "/usr/lib/grass83"
las.dir = "/tmp"
las.crs = "epsg:6568"
crs.lonlat = "epsg:4326"
las.buffer.ft = 500.
nursing.homes = list(
list(name = "Kingston Center for Rehabilitation and Nursing",
lon = -71.61699, lat = 41.54679,
las.files = "USGS_LPC_RI_Statewide_D22_295000_167500.laz"),
list(name = "Mikaela Esau",
lon = -71.59471, lat = 41.67216,
las.files = c("USGS_LPC_RI_Statewide_D22_300000_212500.laz", "USGS_LPC_RI_Statewide_D22_302500_212500.laz")))
for (l in nursing.homes)
{coords = st_coordinates(st_transform(crs = las.crs, st_as_sf(
data.frame(l$lon, l$lat), coords = c(1, 2), crs = crs.lonlat)))
dsm = lidR::rasterize_canopy(
res = 1,
algorithm = lidR::pitfree(),
las = lidR::readLAS(
file.path(las.dir, l$las.files),
select = "xyzr",
filter = do.call(sprintf, c(list("-keep_xy %d %d %d %d"), round(
coords[c(1, 2, 1, 2)] +
c(-1, -1, 1, 1) * las.buffer.ft)))))
w = rgrass::initGRASS(grass.path,
home = tempdir(), SG = dsm, override = T)}
Yeah, this seems to be a lidR issue.
I'm using: