当前位置:首页 >> 电力/水利 >>

AE根据离散点构造Raster并分级显示,再由Raster生成等值线


AE根据离散点构造Raster并分级显示,再由Raster生成等值线
AE绘制等值线的方法有两种:一种是通过TIN,一种是使用IDW等算法构造出Raster,再由Raster生成等值线图。
下面是使用第二种方法,在AE下用axSceneControl显示地图,根据离散点构造Raster并分级显示,再由Raster生成等值线。并指定Raster与等值线SHP

的文件名称。(本程序还附带一些对Raster复制、另存、删除。对SHP文件的自制删除。对目录清理、删除。)代码如下:

public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
/// 运行程序
private void Run_Click(object sender, EventArgs e)
{
//定义等值线临时shape、raster file图层存放路径
string workPath = @"C:\tempfile";
//生成Raster及等值线,"value"为存放在Layer中的数据源字段名
DrawRasterAndContourline(this.axSceneControl1.Scene.get_Layer(0), this.axSceneControl1.Scene, "ppv", workPath, "SolineRaster", "isoline"); //注意Layer这里是取用axSceneControl1最顶层FeatureClass数据,如果FeatureClass不是最顶层,请自己调整
}
/// <summary>
/// 根据离散点构造Raster并生成等值线
/// </summary>
public void DrawRasterAndContourline(ESRI.ArcGIS.Carto.ILayer pLayer, ESRI.ArcGIS.Analyst3D.IScene pScene, string fieldName, string workPath, string rasterName, string contourLineName)
{
//临时目录初始化
if (!System.IO.Directory.Exists(workPath))//如果不存在,则创建
System.IO.Directory.CreateDirectory(workPath);
//重复运行时是否覆盖前面生成的同名文件
string solineRasterFullName = workPath + "\\" + rasterName + ".aux";
string contourLineFullName = workPath + "\\" + contourLineName + ".shp";
System.IO.FileInfo finfo1 = new System.IO.FileInfo(solineRasterFullName);
System.IO.FileInfo finfo2 = new System.IO.FileInfo(contourLineFullName);
if (finfo1.Exists || finfo2.Exists)
{
if (MessageBox.Show("The file is Exists!\n Replace it?", "question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
//移除之前生成的爆炸地点图层
ESRI.ArcGIS.Carto.ILayer pIslineLayer = GetLayerByName(pScene, contourLineName);
ESRI.ArcGIS.Carto.ILayer pSolineRaster = GetLayerByName(pScene, rasterName);
if (pIslineLayer != null) pScene.DeleteLayer(pIslineLayer);
if (pSolineRaster != null) { ESRI.ArcGIS.Carto.IDataLayer2 pDataLayer2 = pSolineRaster as ESRI.ArcGIS.Carto.IDataLayer2; pDataLayer2.Disconnect(); pScene.DeleteLayer(pSolineRaster); }
deleShp(contourLineFullName);
System.IO.FileInfo fSour = new System.IO.FileInfo(solineRasterFullName);
if (fSour.Exists) fSour.Delete(); fSour = null;
clearSpace(workPath + "\\" + rasterName);
clearSpace(workPath + "\\info");
}
else
{
return;
}
}
//定义临时目录
string tempPath = workPath + "\\temp";
//临时目录初始化
if (!System.IO.Directory.Exists(tempPath))//如果不存在,则创建
System.IO.Directory.CreateDirectory(tempPath);
//清除临时目录
clearSpace(tempPath);
System.IO.DirectoryInfo dirInfo = new System.IO.DirectoryInfo(tempPath);
if (!dirInfo.Exists) dirInfo.Create();
//定义FeatureLayer
ESRI.ArcGIS.Carto.IFeatureLayer pFeatureLayer = pLayer as ESRI.ArcGIS.Carto.IFeatureLayer;
//生成Raster数据集
ESRI.ArcGIS.Geodatabase.IGeoDataset createSolineRaster = createraster(pFeatureLayer, fieldName, 25, 2, workPath, tempPath, rasterName, pScene.SpatialReference);
//生成等值线
ESRI.ArcGIS.Geodatabase.IGeoDataset createSoline = contourline(createSolineRaster, 50, tempPath, pScene.SpatialReference);
//获取FeatureLayer要素类
ESRI.ArcGIS.Geodatabase.IFeatureClass pPvFts = pFeatureLayer.FeatureClass;
//计算fieldName字段最大值和最小值
double vauleMax = 0, vauleMin = 0;
ESRI.ArcGIS.Geodatabase.IFeatureCursor pPvFcur = pPvFts.Search(null, false);
ESRI.ArcGIS.Geodatabase.IFeature pPvFt = pPvFcur.NextFeature();
while (pPvFt != null)
{
double fieldValue = (double)pPvFt.get_Value(pPvFt.Fields.FindField(fieldName));
if (vauleMax == 0)
vauleMax = fieldValue;
else if (vauleMax < fieldValue)
vauleMax = fieldValue;
if (vauleMin == 0)
vauleMin = fieldValue;
else if (vauleMin > fieldValue)
vauleMin = fieldValue;
pPvFt = pPvFcur.NextFeature();
}
System.Runtime.InteropServices.Marshal.ReleaseComObject(pPvFcur);
//设置classifyRenderer
ESRI.ArcGIS.Carto.IRasterClassifyColorRampRenderer classifyRenderer = new ESRI.ArcGIS.Carto.RasterClassifyColorRampRendererClass();
int conutSoline = Convert.ToInt32(Convert.ToInt32(vauleMax - vauleMin) / 50); //其中数值50为生成等值线的interval(等值线间距)值
classifyRenderer = createClassifyRenderer(conutSoline, 255, 0, 0, 255, 255, 0);

//定义Raster图层
ESRI.ArcGIS.Carto.IRasterLayer ppvRasterLayer = new ESRI.ArcGIS.Carto.RasterLayer();
if (conutSoline > 0) ppvRasterLayer.Renderer = (ESRI.ArcGIS.Carto.IRasterRenderer)classifyRenderer;
ppvRasterLayer.Name = "SolineRaster";
ESRI.ArcGIS.Geodatabase.IRasterDataset pRasterDataset = (ESRI.ArcGIS.Geodatabase.IRasterDataset)createSolineRaster;
ppvRasterLayer.CreateFromDataset(pRasterDataset);
//添加Raster图层
pScene.AddLayer(ppvRasterLayer, true);
//释放占用资源
System.Runtime.InteropServices.Marshal.ReleaseComObject(classifyRenderer);
classifyRenderer = null;

//在当前文档显示等值线
ESRI.ArcGIS.Geodatabase.IFeatureClass solineFeature = createSoline as ESRI.ArcGIS.Geodatabase.IFeatureClass;
//获取反回的等值线信息
String solineTempLN = solineFeature.AliasName;
String solineTempL = tempPath + "\\" + solineTempLN + ".shp";
//定义等值线名字及路径
String pIsolineFtLayerN = contourLineName;
String pIsolineFtLayer = workPath + "\\" + pIsolineFtLayerN + ".shp";
//复制等值线
copyShp(solineTempL, pIsolineFtLayer);
ESRI.ArcGIS.Carto.IFeatureLayer solineL = new ESRI.ArcGIS.Carto.FeatureLayerClass();
ESRI.ArcGIS.Geodatabase.IWorkspaceFactory pWSF = new ESRI.ArcGIS.DataSourcesFile.ShapefileWorkspaceFactoryClass();
ESRI.ArcGIS.Geodatabase.IFeatureWorkspace pFW = pWSF.OpenFromFile(workPath, 0) as ESRI.ArcGIS.Geodatabase.IFeatureWorkspace;
ESRI.ArcGIS.Geodatabase.IFeatureClass pFcls = pFW.OpenFeatureClass(pIsolineFtLayerN);
solineL.FeatureClass = pFcls;
solineL.Name = solineL.FeatureClass.AliasName;
pScene.AddLayer(solineL as ESRI.ArcGIS.Carto.ILayer, true);

//清除临时文件
delShp(solineTempLN, tempPath);
System.IO.FileInfo fSourLog = new System.IO.FileInfo(tempPath + "\\log");
if (fSourLog.Exists) fSourLog.Delete(); fSourLog = null;
//释放资源
System.Runtime.InteropServices.Marshal.ReleaseComObject(pRasterDataset);
System.Runtime.InteropServices.Marshal.ReleaseComObject(ppvRasterLayer);
System.Runtime.InteropServices.Marshal.ReleaseComObject(createSolineRaster);
pRasterDataset = null;
ppvRasterLayer = null;
createSolineRaster = null;
}
/// <summary>
/// spline生成raster(GP方法)
/// </summary>
/// <param name="pFeatLayer">输入要素图层</param>
/// <param name="munField">源数据字段</param>
/// <param name="out_putrater">输出路径</param>
/// <param name="cellsize">分级间距</param>
/// <returns>函数调用GP结果状态返回(Ture表示成功,Flase表示失败)</returns>
public bool createraster(ESRI.ArcGIS.Carto.IFeatureLayer pFeatLayer, string munField, string out_putrater, double cellsize)
{
//定义新的GP
ESRI.ArcGIS.SpatialAnalystTools.Spline spline = new ESRI.ArcGIS.SpatialAnalystTools.Spline(pFeatLayer, munField, out_putrater);
spline.cell_size = cellsize;
//执行GP并反回执行结果状态
return geoProcessor(spline);
}
/// <summary>
/// spline生成raster(AO方法)
/// </summary>
/// <param name="pFeatLayer">输入要素图层</param>
/// <param name="munField">源数据字段</param>
/// <param name="sRadius">搜索半径</param>
/// <param name="cellsize">Raster精度</param>
/// <param name="spRef">空间参考</param>
/// <returns>返回Raster数据集</returns>
public ESRI.ArcGIS.Geodatabase.IGeoDataset createraster(ESRI.ArcGIS.Carto.IFeatureLayer pFeatLayer, string munField, int sRadius, double cellsize, string workPath, string tempPath, string rasterName, ESRI.ArcGIS.Geometry.ISpatialReference spRef)
{
//定义InterpolationOp
ESRI.ArcGIS.GeoAnalyst.IInterpolationOp pInterpolationOp = new ESRI.ArcGIS.GeoAnalyst.RasterInterpolationOpClass();
object Missing = Type.Missing;

//创建 FeatureClassDescriptor 用munField字段值
ESRI.ArcGIS.GeoAnalyst.IFeatureClassDescriptor pFDescr = new ESRI.ArcGIS.GeoAnalyst.FeatureClassDescriptorClass();
pFDescr.Create(pFeatLayer.FeatureClass, null, munField);

//定义搜索半径
ESRI.ArcGIS.GeoAnalyst.IRasterRadius pRadius = new ESRI.ArcGIS.GeoAnalyst.RasterRadiusClass();
pRadius.SetVariable(sRadius, ref Missing);

//定义工作空间
ESRI.ArcGIS.Geodatabase.IWorkspaceFactory pWorkspaceFactory = new ESRI.ArcGIS.DataSourcesRaster.RasterWorkspaceFactory();
ESRI.ArcGIS.Geodatabase.IWorkspace pShpWorkspace = pWorkspaceFactory.OpenFromFile(tempPath, 0);

//设置数据输出环境变量
object cellSizeProvider = cellsize;
ESRI.ArcGIS.GeoAnalyst.IRasterAnalysisEnvironment pEnv = pInterpolationOp as ESRI.ArcGIS.GeoAnalyst.IRasterAnalysisEnvironment;
pEnv.SetCellSize(ESRI.ArcGIS.GeoAnalyst.esriRasterEnvSettingEnum.esriRasterEnvValue, ref cellSizeProvider);
pEnv.OutSpatialReference = spRef;
pEnv.OutWorkspace = pShpWorkspace;

//执行插置产生结果Raster数据集
ESRI.ArcGIS.Geodatabase.IGeoDataset pSolineRaster = pInterpolationOp.IDW(pFDescr as ESRI.ArcGIS.Geodatabase.IGeoDataset, 2, pRadius, ref Missing);
//释放资源
System.Runtime.InteropServices.Marshal.ReleaseComObject(pEnv);
System.Runtime.InteropServices.Marshal.ReleaseComObject(pFDescr);
System.Runtime.InteropServices.Marshal.ReleaseComObject(pInterpolationOp);
pFDescr = null;
pRadius = null;
pEnv = null;
pInterpolationOp = null;

//用指定文件名另存数据
ESRI.ArcGIS.Geodatabase.IRaster SolineRasterR = pSolineRaster as ESRI.ArcGIS.Geodatabase.IRaster;
//数据另存空间
ESRI.ArcGIS.Geodatabase.IWorkspaceFactory rWorkspaceFactory = new ESRI.ArcGIS.DataSourcesRaster.RasterWorkspaceFactory();
ESRI.ArcGIS.Geodatabase.IWorkspace rasterWorkspace = rWorkspaceFactory.OpenFromFile(workPath, 0);
ESRI.ArcGIS.Geodatabase.ISaveAs saveas = (ESRI.ArcGIS.Geodatabase.ISaveAs)SolineRasterR;
ESRI.ArcGIS.Geodatabase.IDataset SolineRasterS = saveas.SaveAs(rasterName, rasterWorkspace, "GRID");
ESRI.ArcGIS.Geodatabase.IGeoDataset pOutRaster = (ESRI.ArcGIS.Geodatabase.IGeoDataset)SolineRasterS;

//定义TempRasterLayer,获取pSolineRaster文件名
ESRI.ArcGIS.Carto.IRasterLayer TempRasterLayer = new ESRI.ArcGIS.Carto.RasterLayer();
TempRasterLayer.CreateFromRaster(SolineRasterR);
string filepath = TempRasterLayer.FilePath;
//释放资源
System.Runtime.InteropServices.Marshal.ReleaseComObject(pSolineRaster);
System.Runtime.InteropServices.Marshal.ReleaseComObject(SolineRasterR);
System.Runtime.InteropServices.Marshal.ReleaseComObject(TempRasterLayer);
System.Runtime.InteropServices.Marshal.ReleaseComObject(saveas);
pSolineRaster = null;
SolineRasterR = null;
TempRasterLayer = null;
saveas = null;
//清除临时文件
System.IO.FileInfo fSour = new System.IO.FileInfo(filepath + ".aux");
if (fSour.Exists) fSour.Delete(); fSour = null;
clearSpace(filepath);
clearSpace(tempPath + "\\info");

//返回Raster数据集
return pOutRaster;
}
/// <summary>
/// Raster分级显示classifyRenderer设置
/// </summary>
/// <param name="conutSoline">显示分级等级数量</param>
/// <param name="toColorRed">起始色Red值</param>
/// <param name="toColorGreen">起始色Green值</param>
/// <param name="toColorBlue">起始色Blue值</param>
/// <param name="formColorRed">结束色Red值</param>
/// <param name="formColorGreen">结束色Green值</param>
/// <param name="formColorBlue">结束色Blue值</param>
/// <returns>返回classifyRenderer设置</returns>
public ESRI.ArcGIS.Carto.IRasterClassifyColorRampRenderer createClassifyRenderer(int conutSoline, int toColorRed, int toColorGreen, int toColorBlue, int formColorRed, int formColorGreen, int formColorBlue)
{
//配置classifyRenderer
ESRI.ArcGIS.Carto.IRasterClassifyColorRampRenderer classifyRenderer = new ESRI.ArcGIS.Carto.RasterClassifyColorRampRendererClass();
if (conutSoline < 1) conutSoline = 1;
classifyRenderer.ClassCount = conutSoline + 1;
ESRI.ArcGIS.Display.IRgbColor tc = new ESRI.ArcGIS.Display.RgbColor();
ESRI.ArcGIS.Display.IRgbColor fc = new ESRI.ArcGIS.Display.RgbColor();
tc.Red = toColorRed;
tc.Green = toColorGreen;
tc.Blue = toColorBlue;
fc.Red = formColorRed;
fc.Green = formColorGreen;
fc.Blue = formColorBlue;

ESRI.ArcGIS.Display.IAlgorithmicColorRamp colorRamp = new ESRI.ArcGIS.Display.AlgorithmicColorRampClass();
colorRamp.ToColor = tc;
colorRamp.FromColor = fc;
colorRamp.Algorithm = ESRI.ArcGIS.Display.esriColorRampAlgorithm.esriCIELabAlgorithm;
colorRamp.Size = conutSoline + 1;
bool createColorRamp;
colorRamp.CreateRamp(out createColorRamp);
//创建符号
ESRI.ArcGIS.Display.IFillSymbol fillSymbol = new ESRI.ArcGIS.Display.SimpleFillSymbolClass();
for (int i = 0; i < classifyRenderer.ClassCount; i++)
{
fillSymbol.Color = colorRamp.get_Color(i);
classifyRenderer.set_Symbol(i, (ESRI.ArcGIS.Display.ISymbol)fillSymbol);
classifyRenderer.set_Label(i, System.Convert.ToString(i));
}
//释放资源
System.Runtime.InteropServices.Marshal.ReleaseComObject(fillSymbol);
System.Runtime.InteropServices.Marshal.ReleaseComObject(colorRamp);
fillSymbol = null;
colorRamp = null;
//返回classifyRenderer设置
return classifyRenderer;
}
/// <summary>
/// 通过Raster生成等值线(GP方法)
/// </summary>
/// <param name="rastlyr">传入Raster数据</param>
/// <param name="isoline">等值线SHP存放完全路径</param>
/// <param name="interval">生成等值线时各等值线间的间距</param>
/// <returns>函数调用GP结果状态返回(Ture表示成功,Flase表示失败)</returns>
public bool contourline(ESRI.ArcGIS.Geodatabase.IRaster rastlyr, string isoline, double interval)
{
//定义新的GP
ESRI.ArcGIS.SpatialAnalystTools.Contour contourl = new ESRI.ArcGIS.SpatialAnalystTools.Contour(rastlyr, isoline, interval);
contourl.base_contour = 0;
contourl.z_factor = 1;
//执行GP并反回执行结果状态
return geoProcessor(contourl);
}
/// <summary>
/// 通过Raster绘制等值线(AO方法)
/// </summary>
/// <param name="inGeoDataSet">输入Raster数据集</param>
/// <param name="interval">等值线间距</param>
/// <param name="workPath">工作空间路径</param>
/// <param name="spRef">空间参考</param>
/// <returns>返回等值线FeatureClass数据集</returns>
public ESRI.ArcGIS.Geodatabase.IGeoDataset contourline(ESRI.ArcGIS.Geodatabase.IGeoDataset inGeoDataSet, double interval, string workPath, ESRI.ArcGIS.Geometry.ISpatialReference spRef)
{
object Missing = Type.Missing;
//定义工作空间
ESRI.ArcGIS.Geodatabase.IWorkspaceFactory pWorkspaceFactory = new ESRI.ArcGIS.DataSourcesFile.ShapefileWorkspaceFactory();
ESRI.ArcGIS.Geodatabase.IWorkspace pShpWorkspace = pWorkspaceFactory.OpenFromFile(workPath, 0);
//定义ISurfaceOp2
ESRI.ArcGIS.GeoAnalyst.ISurfaceOp2 pSurfaceOp2 = new ESRI.ArcGIS.GeoAnalyst.RasterSurfaceOpClass();
//设置环境变量
ESRI.ArcGIS.GeoAnalyst.IRasterAnalysisEnvironment pRasterAnalysisEnvironment = pSurfaceOp2 as ESRI.ArcGIS.GeoAnalyst.IRasterAnalysisEnvironment;
pRasterAnalysisEnvironment.Reset();
pRasterAnalysisEnvironment.OutWorkspace = pShpWorkspace;
pRasterAnalysisEnvironment.OutSpatialReference = spRef;
//生成等值线
ESRI.ArcGIS.Geodatabase.IGeoDataset pOutDataSet = pSurfaceOp2.Contour(inGeoDataSet, interval, ref Missing, ref Missing);
//释放资源
System.Runtime.InteropServices.Marshal.ReleaseComObject(pRasterAnalysisEnvironment);
System.Runtime.InteropServices.Marshal.ReleaseComObject(pSurfaceOp2);
System.Runtime.InteropServices.Marshal.ReleaseComObject(pShpWorkspace);
pRasterAnalysisEnvironment = null;
pSurfaceOp2 = null;
pShpWorkspace = null;
pWorkspaceFactory = null;
Missing = null;
//返回等值线FeatureClass数据集
return pOutDataSet;
}
/// <summary>
/// 复制一个shapeFile对象
/// </summary>
/// <param name="sour">源文件</param>
/// <param name="target">目标文件</param>
public void copyShp(String sour, String target)
{
System.IO.FileInfo fSour = new System.IO.FileInfo(sour);
if (fSour.Exists) fSour.CopyTo(target, true);
fSour = null;

System.IO.FileInfo fSour1 = new System.IO.FileInfo(sour.Replace(".shp", ".shx"));
if (fSour1.Exists) fSour1.CopyTo(target.Replace(".shp", ".shx"), true);
fSour1 = null;

System.IO.FileInfo fSour2 = new System.IO.FileInfo(sour.Replace(".shp", ".dbf"));
if (fSour2.Exists) fSour2.CopyTo(target.Replace(".shp", ".dbf"), true);
fSour2 = null;

System.IO.FileInfo fSour3 = new System.IO.FileInfo(sour.Replace(".shp", ".prj"));
if (fSour3.Exists) fSour3.CopyTo(target.Replace(".shp", ".prj"), true);
fSour3 = null;

System.IO.FileInfo fSour4 = new System.IO.FileInfo(sour.Replace(".shp", ".shp.xml"));
if (fSour4.Exists) fSour4.CopyTo(target.Replace(".shp", ".shp.xml"), true);
fSour4 = null;

System.IO.FileInfo fSour5 = new System.IO.FileInfo(sour.Replace(".shp", ".sbx"));
if (fSour5.Exists) fSour5.CopyTo(target.Replace(".shp", ".sbx"), true);
fSour5 = null;

System.IO.FileInfo fSour6 = new System.IO.FileInfo(sour.Replace(".shp", ".sbn"));
if (fSour6.Exists) fSour6.CopyTo(target.Replace(".shp", ".sbn"), true);
fSour6 = null;

}
/// <summary>
/// 删除一个shapeFile对象(AO方法)
/// </summary>
/// <param name="fileName">源文件名</param>
public void delShp(string fileName, string workPath)
{
ESRI.ArcGIS.Geodatabase.IWorkspaceFactory pWSF = (ESRI.ArcGIS.Geodatabase.IWorkspaceFactory)new ESRI.ArcGIS.DataSourcesFile.ShapefileWorkspaceFactory();
ESRI.ArcGIS.Geodatabase.IFeatureWorkspace pFW = (ESRI.ArcGIS.Geodatabase.IFeatureWorkspace)pWSF.OpenFromFile(workPath, 0);
ESRI.ArcGIS.Geodatabase.IDataset pDataset = (ESRI.ArcGIS.Geodatabase.IDataset)pFW.OpenFeatureClass(fileName);
if (pDataset.CanDelete())
pDataset.Delete();
else
{
MessageBox.Show("Could not delete the Shapefile");
}
}
/// <summary>
/// 删除一个shapeFile对象(文件方法)
/// </summary>
/// <param name="sour">源文件</param>
public void deleShp(String sour)
{

System.IO.FileInfo fSour = new System.IO.FileInfo(sour);
if (fSour.Exists) fSour.Delete();
fSour = null;

System.IO.FileInfo fSour1 = new System.IO.FileInfo(sour.Replace(".shp", ".shx"));
if (fSour1.Exists) fSour1.Delete();
fSour1 = null;

System.IO.FileInfo fSour2 = new System.IO.FileInfo(sour.Replace(".shp", ".dbf"));
if (fSour2.Exists) fSour2.Delete();
fSour2 = null;

System.IO.FileInfo fSour3 = new System.IO.FileInfo(sour.Replace(".shp", ".prj"));
if (fSour3.Exists) fSour3.Delete();
fSour3 = null;

System.IO.FileInfo fSour4 = new System.IO.FileInfo(sour.Replace(".shp", ".shp.xml"));
if (fSour4.Exists) fSour4.Delete();
fSour4 = null;

System.IO.FileInfo fSour5 = new System.IO.FileInfo(sour.Replace(".shp", ".sbx"));
if (fSour5.Exists) fSour5.Delete();
fSour5 = null;

System.IO.FileInfo fSour6 = new System.IO.FileInfo(sour.Replace(".shp", ".sbn"));
if (fSour6.Exists) fSour6.Delete();
fSour6 = null;
}
/// <summary>
/// 执行GeoProcessor操作
/// </summary>
/// <param name="gpProcess">要执行的动作</param>
/// <returns>GP执行结果状态(Ture表示成功,Flase表示失败)</returns>
public Boolean geoProcessor(ESRI.ArcGIS.Geoprocessor.IGPProcess gpProcess)
{
ESRI.ArcGIS.Geoprocessor.Geoprocessor gp = new ESRI.ArcGIS.Geoprocessor.Geoprocessor();
Boolean retB = true;
try
{
gp.OverwriteOutput = false; gp.ClearMessages(); gp.AddOutputsToMap = true;

ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult results = (ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult)gp.Execute(gpProcess, null);

if (results.Status != ESRI.ArcGIS.esriSystem.esriJobStatus.esriJobSucceeded) retB = false;
}
catch (Exception)
{
retB = false;
}

gp = null;

return retB;

}
/// <summary>
/// 根据图层的名,获取图层
/// </summary>
/// <param name="pSxDoc">地图文档</param>
/// <param name="layerName">图层名</param>
/// <returns>获取到的图层</returns>
public ESRI.ArcGIS.Carto.ILayer GetLayerByName(ESRI.ArcGIS.Analyst3D.IScene pScene, string layerName)
{
if (pScene == null)
return null;
ESRI.ArcGIS.Carto.ILayer player;
for (int i = 0; i < pScene.LayerCount; i++)
{
if (pScene.get_Layer(i).Name == layerName)
{
player = pScene.get_Layer(i);
//清理临时文件
pScene.ClearSelection();
//返回层
return player;
}
}
return null;
}
/// <summary>
/// 清除指定目录下所有数据
/// </summary>
/// <param name="tempPath">指定目录路径</param>
public void clearSpace(string tempPath)
{
System.IO.DirectoryInfo dirInfo = new System.IO.DirectoryInfo(tempPath);
if (dirInfo.Exists)
{
//递归清除当前目录下子目录所有文件
string[] dirs = System.IO.Directory.GetDirectories(tempPath);//得到子目录
System.Collections.IEnumerator iter = dirs.GetEnumerator();
while (iter.MoveNext())
{
string str = (string)(iter.Current);
clearSpace(str);
}
//清除当前目录下所有文件
string[] files = System.IO.Directory.GetFiles(tempPath);
if (files.Length > 0)
{
foreach (string file in files)
{
try
{
System.IO.File.Delete(file);
}
catch
{ continue; }
}
}
try
{
dirInfo.Delete();
}
catch
{ } //不执行任何操作
}
}
}

相关文章:
实验报告
鞍部点等一起 构成了地形及其起伏变化的骨架结构。...在 Input surface raster 文本框中选择原始 DEM ...分类级别 设置为两类, 并以由 DEM 生成等值线...
利用ARCENGINE生成等值线
我想利用 ARCENGINE 生成等值线,在生成等值线前需要先生成表面(surface),利用 I...AE根据离散点构造Raster... 10页 1下载券 ArcEngine开发入门-4 30页 免费 ArcE...
AE复习整理
ae 7页 免费A​E​复​习​整​理 ...(分类符号化) RasterStretchColorRampRenderer Raster...} } 查询图形并高亮显示的代码在光盘第二章第七个...
AE开发之GeoDataBase
分类: 默认分类 | 标签: |字号大中小 订阅 AE ...例如等值线,剖面和 volumetrics 组成的基本元素: ....OpenRasterCatalog("RedLandImages") 在 geodatabase...
AE的raster处理
IMAGINE Image 格式 AE 中一般调用 ISaveAs 接口来保存栅格数据 2、栅格数据集和栅格编目的区别 一个栅格数据集由一个或者多个波段(RasterBand)的数据组成,一...
Arcgis操作 第九章 水文分析
Input raster or feature pour point 文本框中...选择由无洼地 DEM 生成的水流方向栅格数据 fdirfill...分别生成原始 DEM 的等值线图 ctour 和晕渲图 hillshad...
AE对于生成Raster功能的研究
龙源期刊网 http://www.qikan.com.cn AE 对于生成 Raster 功能的研究 作者:林浩 陈辛蕊 刘新洋 来源:《华东科技》2012 年第 12 期 【摘要】Raster 文件时 ...
GMT笔记-GMT常用画图等命令
pshistogram 绘制柱状图 psimage Plot Sun raster...由后面两个字符创建一个合成符号,:.titleA@#AE: ...给最里面的封闭等值线绘制短线,短线起点在等值 线,...
GIS9.3学习笔记
等值线绘制:Spatial Analyst——surface analysis——...(分类区图层) ——Value raster(被用来统计的栅格...(地表某点的可视范围在通信、军事、房地产等应用...
更多相关标签:
c 离散点生成等值线 | 离散点 等值线 | 构造等值线图 | 等值线 | 等值线图 | matlab 等值线 | 等值线的判读方法 | surfer画等值线图 |