private void calculateIDW() { pm = new ProcessManager(); this.Invoke(pm.createProcessWindow()); try { GISdataManager.readSHP(tBPointPath.Text, ref pointLayer); this.Invoke(pm.addInfomation, new object[] { "读取point图层成功" }); } catch (Exception e) { } try { GISdataManager.readRaster(tBRefPath.Text, ref refLayer); this.Invoke(pm.addInfomation, new object[] { "读取参考图层成功" }); } catch (Exception e) { } path = tBSavePath.Text; fileName = Path.GetFileName(path); filePath = Path.GetDirectoryName(path); Console.WriteLine(fileName + "," + filePath); IFeatureClass pointFeature = pointLayer.FeatureClass; IRaster refRaster = refLayer.Raster; List <String> fields = new List <string>(); for (int i = 0; i < pointFeature.Fields.FieldCount; i++) { var name = pointFeature.Fields.Field[i].Name; if (Regex.IsMatch(name, @"^\d+_\d+_\d+$")) { fields.Add(name); } } this.Invoke(pm.setProcess, new object[] { 0, fields.Count }); int key = 1; foreach (var field in fields) { this.Invoke(pm.updateProcess, new object [] { string.Format("正在生成第{0}副图像", key), key }); IDWInterpolation(pointFeature, refRaster, field); this.Invoke(pm.addInfomation, new object[] { string.Format("第{0}副图像生成成功", key) }); key++; } this.Invoke(pm.close); }
void FloodStart() { //读入dem,manning,rain DemPath = txbDemIpute.Text; GISdataManager.readRaster(DemPath, ref demRaster); dem = GISdataManager.Raster2Mat(demRaster); ManningPath = txbManingInput.Text; GISdataManager.readRaster(ManningPath, ref manningRaster); manNing = GISdataManager.Raster2Mat(manningRaster); RainRecordPath = txbRaintxt.Text; rainRecordList = TxTReader.txt2List2(RainRecordPath); if (rainRecordList.Count > 0) { string[] record = rainRecordList[0]; string path; path = record[1]; GISdataManager.readRaster(path, ref rainDeepRaster); rainDeepMat = GISdataManager.Raster2Mat(rainDeepRaster); } else { MessageBox.Show("请重新输入有效降雨数据!"); return; } //获取栅格分辨率 IRasterInfo rasterinfo = (demRaster.Raster as IRawBlocks).RasterInfo; flowLength = Convert.ToInt32(rasterinfo.CellSize.X); flowLength2 = flowLength * 1.141f; //判断DEM与曼宁系数栅格是否一致! if (demRaster.ColumnCount != manningRaster.ColumnCount || demRaster.RowCount != manningRaster.RowCount) { MessageBox.Show("请保证曼宁糙率栅格行列是否与DEM一致,请对应后重新输入!"); return; } rowCount = demRaster.RowCount; colCount = demRaster.ColumnCount; //初始化中间参数 slope = new float[rowCount, colCount]; flowDir = new byte[rowCount, colCount]; canCuculate = new bool[rowCount, colCount]; waterDeep = new float[rowCount, colCount]; tempDeep = new float[rowCount, colCount]; flowVel = new float[rowCount, colCount]; arrived = new bool[rowCount, colCount]; for (int i = 0; i < rowCount; i++) { for (int j = 0; j < colCount; j++) { slope[i, j] = 0f; flowDir[i, j] = 0; waterDeep[i, j] = 0f; tempDeep[i, j] = 0f; flowVel[i, j] = 0f; arrived[i, j] = false; } } DBpointPath = txbDBpoint.Text; GISdataManager.readSHP(DBpointPath, ref DBpointshp); IFeatureClass featureClass = DBpointshp.FeatureClass; int count = featureClass.FeatureCount(new QueryFilter()); for (int i = 0; i < count; i++) { IFeature feature = featureClass.GetFeature(i); IGeometry Geo = feature.Shape; IPoint point = Geo as IPoint; double x, y; x = point.X; y = point.Y; //获取出水点在Mit中的位置 IRaster raster = demRaster.Raster; IRaster2 raster2 = raster as IRaster2; DPcolIndex = raster2.ToPixelColumn(x); DProwIndex = raster2.ToPixelRow(y); dbPointList.Add(new int[2] { DProwIndex, DPcolIndex }); arrived[DProwIndex, DPcolIndex] = true; } //读取流量过程线表格 HydroPath = txbHydroghraph.Text; HydroRecordList = TxTReader.txt2List3(HydroPath, dbPointList.Count); //初始化计算范围 for (int i = 0; i < rowCount; i++) { for (int j = 0; j < colCount; j++) { if (dem[i, j] != nodataValue) { canCuculate[i, j] = true; } } } }
void DemBreakStart() { //读入dem,manning DemPath = txbDemIpute.Text; GISdataManager.readRaster(DemPath, ref demRaster); // //IRasterProps rasterprops = demRaster.Raster as IRasterProps; //object nodataValue1 = rasterprops.NoDataValue; //float[] mit = nodataValue1 as float[]; //nodataValue = mit[0]; // dem = GISdataManager.Raster2Mat(demRaster); ManningPath = txbManingInput.Text; GISdataManager.readRaster(ManningPath, ref manningRaster); manNing = GISdataManager.Raster2Mat(manningRaster); //获取栅格分辨率 IRasterInfo rasterinfo = (demRaster.Raster as IRawBlocks).RasterInfo; flowLength = Convert.ToInt32(rasterinfo.CellSize.X); flowLength2 = flowLength * 1.141f; //判断DEM与曼宁系数栅格是否一致! if (demRaster.ColumnCount != manningRaster.ColumnCount || demRaster.RowCount != manningRaster.RowCount) { MessageBox.Show("请在检查DEM与曼宁糙率栅格行列是否对应后重新输入!"); return; } rowCount = demRaster.RowCount; colCount = demRaster.ColumnCount; //初始化中间参数 slope = new float[rowCount, colCount]; flowDir = new byte[rowCount, colCount]; waterDeep = new float[rowCount, colCount]; tempDeep = new float[rowCount, colCount]; flowVel = new float[rowCount, colCount]; arrived = new bool[rowCount, colCount]; for (int i = 0; i < rowCount; i++) { for (int j = 0; j < colCount; j++) { slope[i, j] = 0f; flowDir[i, j] = 0; waterDeep[i, j] = 0f; tempDeep[i, j] = 0f; flowVel[i, j] = 0f; arrived[i, j] = false; } } DBpointPath = txbDBpoint.Text; GISdataManager.readSHP(DBpointPath, ref DBpointshp); IFeatureClass featureClass = DBpointshp.FeatureClass; int count = featureClass.FeatureCount(new QueryFilter()); for (int i = 0; i < count; i++) { IFeature feature = featureClass.GetFeature(i); IGeometry Geo = feature.Shape; IPoint point = Geo as IPoint; double x, y; x = point.X; y = point.Y; //获取出水点在Mit中的位置 IRaster raster = demRaster.Raster; IRaster2 raster2 = raster as IRaster2; DPcolIndex = raster2.ToPixelColumn(x); DProwIndex = raster2.ToPixelRow(y); dbPointList.Add(new int[2] { DProwIndex, DPcolIndex }); arrived[DProwIndex, DPcolIndex] = true; waterGrids.Add(new int[2] { DProwIndex, DPcolIndex }); } //读取流量过程线表格 HydroPath = txbHydroghraph.Text; HydroRecordList = TxTReader.txt2List3(HydroPath, dbPointList.Count); }