如何实现 ArcEngine+C# 中实现栅格数据投影转换?求救,急急!!!答案有帮助的加分。

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何实现 ArcEngine+C# 中实现栅格数据投影转换?求救,急急!!!答案有帮助的加分。相关的知识,希望对你有一定的参考价值。

源代码大致如下:
igp= new ESRI.ArcGIS.Geoprocessor.Geoprocessor();

pror = new ProjectRaster();

//IRaster newRaster = new RasterClass();
//再进行投影
//构造Geoprocessor

//pror.in_coor_system = oldsr;//oldsr.Name"GCS_WGS_1984"
pror.out_coor_system = oldsr;//.Name; "World_Mercator"
pror.in_raster = pRaster;// @"E:\TestData\gisrs\reclassify\reclass.img";
pror.out_raster =@"E:\TestData\gisrs\reclassify\out.img";// newRaster;
// pror.cell_size = 68818;
//pror.cell_size = pProps.MeanCellSize().X;
pror.resampling_type = "NEAREST";

// pror.re

//执行project raster工具
RunTool(igp, pror, null);
private void RunTool(Geoprocessor geoprocessor, IGPProcess process, ITrackCancel TC)

// Set the overwrite output option to true
geoprocessor.OverwriteOutput = true;
geoprocessor.AddOutputsToMap = true;
try

// geoprocessor.Execute(
geoprocessor.Execute(process, null);
ReturnMessages(geoprocessor);


catch (Exception err)

Console.WriteLine(err.Message);
ReturnMessages(geoprocessor);


参考技术A 搜索半天没一个靠谱的答案,自己写了一个下面 的代码仅供参考public bool ChangeRasterCoordinate(string prjPath, string inputRasterPath, string outRasterPath)

var prj = SpatialReferenceHelper.ReadSR(prjPath);//prjPath即你要转换成的坐标系的prj文件;inputRasterPath:需要转换的文件路径;outRasterPath转换完成后的文件路径
Geoprocessor gp = new Geoprocessor();
ProjectRaster projectRaster = new ProjectRaster();
projectRaster.in_raster = inputRasterPath;
projectRaster.out_raster = outRasterPath;
projectRaster.cell_size = "10000";
projectRaster.out_coor_system = prj;
IGeoProcessorResult tGPResult = (IGeoProcessorResult)gp.Execute(projectRaster, null);
if (tGPResult.Status == ESRI.ArcGIS.esriSystem.esriJobStatus.esriJobSucceeded)

return true;

return false;
参考技术B 下面是Desktop里面这个Tool参数的说明,我觉得问题可能出现在下面这点的设置上

geographic_transform (Required)

The transformation method used between two geographic systems or datums.

The geographic transformation is optional when the input and output coordinate systems have the same datum. If the input and output datum are different, a geographic transformation needs to be specified.

Learn about geographic transformation methods.

For information on each supported geographic (datum) transformations, see the geographic_transformations.pdf located in <install location>\ArcGIS\Documentation.本回答被提问者采纳

C#+arcengine获得栅格数据的属性表

此文为或的栅格数据的属性表的功能,在此,我的属性表中有count和value字段,其中value是栅格数据的高程值,count是value在影像中出现的次数,此程序的功能为得到count最大的数,以此来获得对应的value即此栅格影像的高程值的众数,如下:

///

    /// 获得属性表
    /// </summary>
    /// <param name=”maskTifPath”>raster的路径</param>
    private int GetAttributeTable(string maskPath)
    
       int elevation=0;//高程
        //得到raster(见另外的博文获得栅格数据)
       IRaster raster=GetRaster(maskPath);
      if (raster != null)
       
           try
            
             //得到一段光栅带
               IRasterBandCollection rasterBandCollection = (IRasterBandCollection)raster;
              int bandCount = rasterBandCollection.Count;//bandCount=1
               for (int j = 0; j < bandCount; j++)
               
                    IRasterBand rasterBand = rasterBandCollection.Item(j);
                  //得到此光栅带的属性表,并保存到table
                    ITable table = rasterBand.AttributeTable;
                  //创建一个查询(SQL语句)
                  IQueryFilter queryFilter = new QueryFilterClass();
                   queryFilter.WhereClause = “”;
                   //用queryFilter查询表,并把结果保存到游标指针中去 
                   ICursor cursorCount = table.Search(queryFilter, false);
                    IRow rowCount = cursorCount.NextRow();
                    //  count字段集合
                   List<int> countCol = new List<int>();
                   int MaxValue = 0;
                   for (int i = 0; i < table.Fields.FieldCount; i++)//field.count=4
                    
                      //判断字段名称是否为count
                       if (table.Fields.get_Field(i).Name == “Count”)
                       
                         while (rowCount != null)
                          
                                //以下显示Count字段的值,并得到count值的集合
                              countCol.Add(Convert.ToInt32(rowCount.get_Value(table.FindField(“Count”))));
                               rowCount = cursorCount.NextRow();
                           
                            int count = countCol.Count;
                            //得到字段Count的最大值
                         MaxValue = countCol[0];
                           for (int w = 1; w < count; w++)
                           
                              if (countCol[w] > MaxValue)
                               
                                  MaxValue = countCol[w];
                              
                           
                           //得到Count最大时value的值,即为高程的众数
                          ICursor cursorBinvalues = table.Search(queryFilter, false);
                        IRow rowBinvalues = cursorBinvalues.NextRow();
                         while (rowBinvalues != null)
                          
                             int value = Convert.ToInt32(rowBinvalues.get_Value(table.FindField(“Count”)));
                               if (value == MaxValue)
                           
                                 elevation = Convert.ToInt32(rowBinvalues.get_Value(table.FindField(“Value”)));
                             
                            rowBinvalues = cursorBinvalues.NextRow();
                           
                    
                       else
                      
                           //字段名称不是count,无用,往下判断
                      
                   
               
              return elevation;
         
       catch (Exception ex)
           
              Console.WriteLine(ex.Message);
              return 0;
           
        
       else
     
           MessageBox.Show(“提取栅格数据失败!”);
            return 0; 
       

   

本文参照了http://blog.csdn.net/gisoracle/article/details/4297650博文,博主很强大,在次拜谢

转载自:https://blog.csdn.net/chhdxzq/article/details/43453569

以上是关于如何实现 ArcEngine+C# 中实现栅格数据投影转换?求救,急急!!!答案有帮助的加分。的主要内容,如果未能解决你的问题,请参考以下文章

C#+arcengine获得栅格数据的属性表

arcEngine开发之加载栅格数据

ArcEngine 栅格数据 总结

ArcEngine 栅格数据 总结

Arcgis中栅格山脊线如何转换成矢量线

ArcEngine中如何将图形转换为要素