洪涝淹没分析输出淹没范围图、深度图及面积体积等信息【转】
http://blog.csdn.net/giser_whu/article/details/41308771
接上一篇博客《洪涝有源淹没算法及结果分析》。可以输出洪涝淹没范围图、深度图以及淹没面积等信息,下一步输出历时图。代码很简单,下面直接给出源代码,欢迎大家留言交流。
- /// <summary>
- /// 输出洪涝淹没范围图
- /// </summary>
- public void OutPutFloodRegion()
- {
- //创建洪涝淹没范围影像
- string m_FloodRegionPath = System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\FloodSimulation\\FloodedRegion.tif";
- if (System.IO.File.Exists(m_FloodRegionPath))
- {
- System.IO.File.Delete(m_FloodRegionPath);
- }
- //在GDAL中创建影像,先需要明确待创建影像的格式,并获取到该影像格式的驱动
- driver = Gdal.GetDriverByName("GTiff");
- //调用Creat函数创建影像
- m_FloodSimulationRegionDataSet = driver.Create(m_FloodRegionPath, m_XSize, m_YSize, 1, DataType.GDT_Float32, null);
- //设置影像属性
- m_FloodSimulationRegionDataSet.SetGeoTransform(m_adfGeoTransform); //影像转换参数
- m_FloodSimulationRegionDataSet.SetProjection(m_DEMDataSet.GetProjectionRef()); //投影
- //输出影像
- m_FloodSimulationRegionDataSet.GetRasterBand(1).WriteRaster(0, 0, m_XSize, m_YSize, m_FloodRegionBuffer, m_XSize, m_YSize, 0, 0);
- m_FloodSimulationRegionDataSet.GetRasterBand(1).FlushCache();
- m_FloodSimulationRegionDataSet.FlushCache();
- }
- /// <summary>
- /// 输出洪涝淹没深度图
- /// </summary>
- public void OutPutFloodDepth()
- {
- for (int i = 0; i < m_XSize; i++)
- {
- for (int j = 0; j < m_YSize; j++)
- {
- Point m_point = new Point();
- m_point.X = i;
- m_point.Y = j;
- if (m_FloodRegionBuffer[getIndex(m_point)] == 1)
- {
- int evaluation = m_DEMdataBuffer[getIndex(m_point)]; //淹没格网高程值
- int value = pFloodLevel - evaluation;
- m_FloodDepthBuffer[getIndex(m_point)] = value;
- }
- }
- }
- //输出洪涝淹没深度图
- string m_FloodDepthPath = System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\FloodSimulation\\FloodedDepth.tif";
- if (System.IO.File.Exists(m_FloodDepthPath))
- {
- System.IO.File.Delete(m_FloodDepthPath);
- }
- //在GDAL中创建影像,先需要明确待创建影像的格式,并获取到该影像格式的驱动
- driver = Gdal.GetDriverByName("GTiff");
- //调用Creat函数创建影像
- m_FloodSimulationDepthDateSet = driver.Create(m_FloodDepthPath, m_XSize, m_YSize, 1, DataType.GDT_Float32, null);
- //设置影像属性
- m_FloodSimulationDepthDateSet.SetGeoTransform(m_adfGeoTransform); //影像转换参数
- m_FloodSimulationDepthDateSet.SetProjection(m_DEMDataSet.GetProjectionRef()); //投影
- //输出影像
- m_FloodSimulationDepthDateSet.GetRasterBand(1).WriteRaster(0, 0, m_XSize, m_YSize, m_FloodDepthBuffer, m_XSize, m_YSize, 0, 0);
- m_FloodSimulationDepthDateSet.GetRasterBand(1).FlushCache();
- m_FloodSimulationDepthDateSet.FlushCache();
- }
- /// <summary>
- /// 输出洪涝淹没面积及水量
- /// </summary>
- public void OutPutFloodInfo()
- {
- int count = 0;
- for (int i = 0; i < m_XSize; i++)
- {
- for (int j = 0; j < m_YSize; j++)
- {
- Point m_point = new Point();
- m_point.X = i;
- m_point.Y = j;
- if (m_FloodRegionBuffer[getIndex(m_point)] == 1)
- {
- count++;
- }
- }
- }
- //统计面积
- double S = count * 90; //平方米
- if (S > 10000)
- {
- S = S / 10000; //公顷
- }
- MessageBox.Show("淹没面积:" + S.ToString() + "公顷");
- }
结果图:范围图与深度图
饮水思源,不忘初心。
要面包,也要有诗和远方。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
2015-12-26 几种支持动作模型格式的比较(MD2,MD5,sea3d) 【转】