获取指定坐标处的栅格单元格的值
private double getRasterCellValue(IPoint pPoint, IRasterLayer pRasterLayer)
{
IIdentify pIdentify = (IIdentify)pRasterLayer;
IArray pArray = pIdentify.Identify(pPoint);
IRasterIdentifyObj2 pRasterIdentify2 = (IRasterIdentifyObj2)pArray.get_Element(0);
//IRasterIdentifyObj pRasterIdentify = (IRasterIdentifyObj)pArray.get_Element(0);
string pField = "";
string pValue = "";
//pField = pRasterIdentify.Name;
if (pField == "NoData")
return 0;
int pIdentifyIndex = 0;
while (true)
{
try
{
pRasterIdentify2.GetPropAndValues(pIdentifyIndex, out pField, out pValue);
}
catch
{
break;
}
pIdentifyIndex = pIdentifyIndex + 1;
}
return Convert.ToDouble(pValue);
}
private double[] getRasterCellValue(IPoint pPoint, IGroupLayer pGroupLayer)
{
IIdentify pIdentify = (IIdentify)pGroupLayer;
IArray pArray = pIdentify.Identify(pPoint);
double[] RasterCellValue = new double[pArray.Count];
for (int i = 0; i < pArray.Count; i++)
{
IRasterIdentifyObj2 pRasterIdentify2 = (IRasterIdentifyObj2)pArray.get_Element(i);
IRasterIdentifyObj pRasterIdentify = (IRasterIdentifyObj)pArray.get_Element(i);
string pField = "";
string pValue = "";
pField = pRasterIdentify.Name;
if (pField == "NoData")
return RasterCellValue;
int pIdentifyIndex = 0;
while (true)
{
try
{
pRasterIdentify2.GetPropAndValues(pIdentifyIndex, out pField, out pValue);
}
catch
{
break;
}
if (pField == "Pixel value" && pValue != "")
RasterCellValue[i] = Convert.ToDouble(pValue);
pIdentifyIndex = pIdentifyIndex + 1;
}
}
return RasterCellValue;
}
posted on 2010-10-08 13:50 kisstome88 阅读(841) 评论(0) 编辑 收藏 举报