Hi @istvanv. I haven't used the lidR package before, but it sounds like it reads LAS and LAZ files directly. You should therefore read your LAS from its file path in the RCaller, not pass it as a data frame. If you've already done some transformation on it using FME, you would have to write it out with a FeatureReader directly before the RCaller.
Regardless, in the RCaller it sounds like you can use the readLAS() function with the path to your LAS. You could hardcode this into the script, or you could pass the path as a parameter from FME. It could be stored as a user parameter or read from the format attribute fme_dataset (which would have to be exposed on the reader feature type or using an AttributeExposer).
The same goes for getting your LAS back into FME if you need to do that. Write it out using writeLAS() and pass the path back to FME to the new or modified dataset in the fmeOutput data frame. Then use a FeatureReader to read the LAS back into FME.
So, to summarize, your workflow would be something like this:
Read LAS in FME -> transform using FME -> write LAS out using FeatureReader -> pass path to RCaller as attribute -> use readLAS() in the RCaller with the path from FME -> transform using R -> write out using writeLAS() -> pass the path to FME through the FMEOutput dataframe -> read LAS back into FME using the FeatureReader -> any additional FME transformation -> write out to LAS using FME.
There might be a slightly more efficient workflow if any R packages support turning a data frame into a LAS object, but I'm not familiar enough to know if that is the case.
I hope this helps. Let me know if you have any more questions.
Hi @istvanv. I haven't used the lidR package before, but it sounds like it reads LAS and LAZ files directly. You should therefore read your LAS from its file path in the RCaller, not pass it as a data frame. If you've already done some transformation on it using FME, you would have to write it out with a FeatureReader directly before the RCaller.
Regardless, in the RCaller it sounds like you can use the readLAS() function with the path to your LAS. You could hardcode this into the script, or you could pass the path as a parameter from FME. It could be stored as a user parameter or read from the format attribute fme_dataset (which would have to be exposed on the reader feature type or using an AttributeExposer).
The same goes for getting your LAS back into FME if you need to do that. Write it out using writeLAS() and pass the path back to FME to the new or modified dataset in the fmeOutput data frame. Then use a FeatureReader to read the LAS back into FME.
So, to summarize, your workflow would be something like this:
Read LAS in FME -> transform using FME -> write LAS out using FeatureReader -> pass path to RCaller as attribute -> use readLAS() in the RCaller with the path from FME -> transform using R -> write out using writeLAS() -> pass the path to FME through the FMEOutput dataframe -> read LAS back into FME using the FeatureReader -> any additional FME transformation -> write out to LAS using FME.
There might be a slightly more efficient workflow if any R packages support turning a data frame into a LAS object, but I'm not familiar enough to know if that is the case.
I hope this helps. Let me know if you have any more questions.
This is what my workflow looks like so far,
Read las -> create path -> write las -> read path which is pathname/fme_basename.las
Sadly it says the file doesn't exist
I know I read somewhere that _attributes need to be renamed for Rcaller
I bet it's something very small, but I can't see it
This is what my workflow looks like so far,
Read las -> create path -> write las -> read path which is pathname/fme_basename.las
Sadly it says the file doesn't exist
I know I read somewhere that _attributes need to be renamed for Rcaller
I bet it's something very small, but I can't see it
Hi @istvanv thanks for the context. Are you on Windows by chance? R does not work well with Windows paths. It requires a UNIX forward slash / in all paths. I see you have that in the concatenated path in the RCaller, but if you are on Windows I believe your Output$pathname would still contain backslashes \\, which R would not accept. You might want to test printing your path in R to confirm it is properly formed, and of course, double-checking the FeatureWriter is successfully writing to that location.
There are several ways to work with paths in R and people have strong opinions about them. 😀
You might want to consider using the file.path() function to create your path in R, or using a StringReplacer to replace any Windows \\ with \\\\. Using a library to handle paths ensures the workspace will work on any OS, which might be important if you plan on sharing this workspace or publishing it to FME Server.
This is what my workflow looks like so far,
Read las -> create path -> write las -> read path which is pathname/fme_basename.las
Sadly it says the file doesn't exist
I know I read somewhere that _attributes need to be renamed for Rcaller
I bet it's something very small, but I can't see it
wooohoo, that thing helped, ended up using the here() package.
I'm still gonna have to figure out the writting part.
Thank you very much for your help
This is what my workflow looks like so far,
Read las -> create path -> write las -> read path which is pathname/fme_basename.las
Sadly it says the file doesn't exist
I know I read somewhere that _attributes need to be renamed for Rcaller
I bet it's something very small, but I can't see it
Great, glad to hear that worked! R paths can be tricky. Good luck with the rest.