private void btnGO_Click(object sender, EventArgs e) { string fileName; string shpFile; int startX, endX; string shpDir; try { if (bDataPath == true) { fileName = txtOutPath.Text; shpDir = fileName.Substring(0, fileName.LastIndexOf("\\")); startX = fileName.LastIndexOf("\\"); endX = fileName.Length; shpFile = fileName.Substring(startX + 1, endX - startX - 1); } else { shpDir = txtOutPath.Text; shpFile = "팃똑"; } if (m_pRasterLyr != null) { double dCellSize = Convert.ToDouble(txtCellSize.Text); ISurfaceOp pRasterSurfaceOp = Utility.SetRasterSurfaceAnalysisEnv(shpDir, dCellSize); double dZFactor = Convert.ToDouble(txtZFactor.Text); object objZFactor = dZFactor; IRaster pInRaster = m_pRasterLyr.Raster; IRaster pOutRaster = null; IRasterLayer pRasterLayer = new RasterLayerClass(); if (radioDegree.Checked == true) { pOutRaster = pRasterSurfaceOp.Slope(pInRaster as IGeoDataset, esriGeoAnalysisSlopeEnum.esriGeoAnalysisSlopeDegrees, ref objZFactor) as IRaster; } else { pOutRaster = pRasterSurfaceOp.Slope(pInRaster as IGeoDataset, esriGeoAnalysisSlopeEnum.esriGeoAnalysisSlopePercentrise, ref objZFactor) as IRaster; } pRasterLayer.Name = "팃똑邏목"; Utility.ConvertRasterToRsDataset(shpDir, pOutRaster, "팃똑邏목"); pRasterLayer = Utility.SetStretchRenderer(pOutRaster); pMainFrm.getMapControl().AddLayer(pRasterLayer, 0); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
//坡度计算 private void button1_Click(object sender, EventArgs e) { if (outGeodataset != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(outGeodataset); } outGeodataset = surfaceOp.Slope(inGeodataset, slopeEnum, ref Missing); ShowRasterResult(outGeodataset, "Slope"); }