我已经看到R的Landsat8包中的命令能够在R控制台中运行它们现在我想从java中以R脚本传递这些命令。
我想将诸如reflcon(),reclassify()之类的landsat8命令从java传递给R.我不知道怎样将landsat8 band作为输入传递给来自java的R?你能否建议任何更好的链接
package pkg;
import org.rosuda.REngine.REXPMismatchException;
import org.rosuda.REngine.Rserve.RConnection;
import org.rosuda.REngine.Rserve.RserveException;
public class Tempuser {
public static void main(String[] args) {
RConnection connection = null;
try {
connection = new RConnection();
connection.eval("source('D:\\\\MyScript.R')");
int num1=10;
int num2=20;
int sum=connection.eval("myAdd("+num1+","+num2+")").asInteger();
System.out.println("The sum is=" + sum);
}
catch (RserveException e)
{
e.printStackTrace();
}
catch (REXPMismatchException e)
{
e.printStackTrace();
}
}
}
<b> R script </b>
myAdd=function(x,y)
{
sum=x+y
return(sum)
}