ArcEngine DEM叠加影像
代码执行前:
代码执行后:
影像叠加代码:
/// <summary> /// 叠加DEM /// </summary> /// <param name="pRasterLayer">DEM栅格</param> /// <param name="pOutRastLay">影像栅格</param> private void SufraceDEM(IRasterLayer pRasterLayer, IRasterLayer pOutRastLay) { IRasterSurface pRasterSurface = new RasterSurface(); pRasterSurface.PutRaster(pRasterLayer.Raster, 0); ISurface pSurface = pRasterSurface as ISurface; ILayerExtensions pLayExtensions = pOutRastLay as ILayerExtensions; I3DProperties p3DProperties = null; for (int i = 0; i < pLayExtensions.ExtensionCount; i++) { if (pLayExtensions.get_Extension(i) is I3DProperties) { p3DProperties = pLayExtensions.get_Extension(i) as I3DProperties; } } p3DProperties.ZFactor =5; //夸张系数 p3DProperties.BaseOption = esriBaseOption.esriBaseSurface; p3DProperties.BaseSurface = pSurface; p3DProperties.Apply3DProperties(pOutRastLay); }
按钮调用代码:
ILayer pLayer = getLayerByname("dem_project.tif"); IRasterLayer pDemRasterLayer = pLayer as IRasterLayer; ILayer pImgLayer = getLayerByname("sx_img_3857.tif"); IRasterLayer pImgRasterLayer = pImgLayer as IRasterLayer; SufraceDEM(pDemRasterLayer, pImgRasterLayer); axSceneControl1.SceneGraph.RefreshViewers();
getLayerByname方法:
/// <summary> /// 获取指定图层通过名称 /// </summary> private ILayer getLayerByname(String name) { ILayer layer = null; int count = axSceneControl1.Scene.LayerCount; if (count == 0) MessageBox.Show("请加载图层"); for (int i = 0; i < count; i++) { layer = axSceneControl1.Scene.get_Layer(i); if (name == layer.Name.ToString()) { break; } } return layer; }
另外扩展一下影像叠加TIN的方法:
/// <summary> /// 叠加TIN /// </summary> private void AddTINSufrace(IRasterLayer pOutRastLay, ITin tin) { ITinAdvanced pTINAdvanced = tin as ITinAdvanced; ISurface pSurface = pTINAdvanced.Surface; ILayerExtensions pLayExtensions = pOutRastLay as ILayerExtensions; I3DProperties p3DProperties = null; for (int i = 0; i < pLayExtensions.ExtensionCount; i++) { if (pLayExtensions.get_Extension(i) is I3DProperties) { p3DProperties = pLayExtensions.get_Extension(i) as I3DProperties; } } p3DProperties.ZFactor =3; p3DProperties.BaseOption = esriBaseOption.esriBaseSurface; p3DProperties.BaseSurface = pSurface; p3DProperties.Apply3DProperties(pOutRastLay); }
TIN叠加调用:
ILayer layer = getLayerByname("Tin"); ITinLayer tinlayer = layer as ITinLayer; ILayer pImgLayer = getLayerByname("sx_img_3857.tif"); IRasterLayer pImgRasterLayer = pImgLayer as IRasterLayer; AddTINSufrace(pImgRasterLayer, tinlayer.Dataset);
posted on 2017-03-11 12:54 Geography爱好者 阅读(2401) 评论(1) 编辑 收藏 举报