AE+C#开发问题之五——地图代数ERROR 010328: Syntax error at or near symbol NEW-LINE.

最近在使用地图代数计算两个或者几个栅格数据的最大值、最小值、平均值的时候,遇到如下问题:


先粘贴下代码:

            IGeoDataset tempGeodata1 = pRaster1 as IGeoDataset;//
            IGeoDataset tempGeodata2 = pRaster2 as IGeoDataset;
            IMapAlgebraOp rsalgebra = new RasterMapAlgebraOpClass();
            //设置栅格运算空间
            IRasterAnalysisEnvironment rasAnaEnv = (IRasterAnalysisEnvironment)rsalgebra;
            IWorkspaceFactory wsf = new FileGDBWorkspaceFactory();
            IWorkspace ws = wsf.OpenFromFile(m_projextdatapath + "\\" + m_projextgdbname, 0);//设置输出空间
            rasAnaEnv.OutWorkspace = ws;
            rsalgebra.BindRaster(tempGeodata1, "F");
            rsalgebra.BindRaster(tempGeodata2, "T");
            IGeoDataset outGetDataset = null;
            if (operatename == "MAX")
            {
                outGetDataset = rsalgebra.Execute("con([F]>[T],[F],[T])");
            }
            if (operatename == "MIN")
            {
                outGetDataset = rsalgebra.Execute("con([F]<[T],[F],[T])");
            }
            if (operatename == "MEAN")
            {
                outGetDataset = rsalgebra.Execute("([F]+[T]) / 2") ;
            }
            return outGetDataset;
最大值错误:
ERROR 010316: Unable to open the input raster: E:\项目\TEMPLATE.GDB\G_G528>E:\项目\TEMPLATE.GDB\G_G529
ERROR 010067: Error in executing grid expression.

最小值错误:
ERROR 010316: Unable to open the input raster: E:\项目\TEMPLATE.GDB\G_G808 ERROR 010067: Error in executing grid expression.

平均值错误:
ERROR 010328: Syntax error at or near symbol NEW-LINE.
ERROR 010267: Syntax error in parsing grid expression.


经过反复试以及网友提供的方法,是因为空格的问题,拿最大值为例:

错误写法:

outGetDataset = rsalgebra.Execute("con([F]>[T],[F],[T])");

正确写法:

outGetDataset = rsalgebra.Execute("con([F] > [T],[F],[T])");

也就是说加了空格就没问题,就这么一个小的问题,或者arcengine接口解析的时候,是根据空格来判断运算符。




你可能感兴趣的:(Programming,language)