/// <summary> /// 创建slopeMap,设置无效值 /// </summary> /// <param name="DemPath"></param> /// <param name="OutSlpPath"></param> static void CreateSlopeMap() { double dsm_NoDataValue; int dsm_HasNoDataValue; OSGeo.GDAL.Band dsmBand = dsmDataset.GetRasterBand(1); dsmBand.GetNoDataValue(out dsm_NoDataValue, out dsm_HasNoDataValue); //调用GDal创建slope影像 if (File.Exists(slopePath)) { gdalDriver.Delete(slopePath); } slopeDataSet = gdalDriver.Create(slopePath, dsm_Xsize, dsm_Ysize, 1, OSGeo.GDAL.DataType.GDT_Float32, null); slopeDataSet.SetProjection(dsmDataset.GetProjection()); slopeDataSet.SetGeoTransform(dsm_Transform); OSGeo.GDAL.Band slopeBand = slopeDataSet.GetRasterBand(1); //设置无效值 if (dsm_HasNoDataValue == 0) //dsm没有无效值 { //把DSM和SLOPE全设置成用户指定的值 dsmBand.SetNoDataValue(imgNodata); slopeBand.SetNoDataValue(imgNodata); } else //DSM有无效值时 { //把SLOPE和全局变量设置成DSM的无效值 imgNodata = dsm_NoDataValue; slopeBand.SetNoDataValue(dsm_NoDataValue); } // BufferOnePixel(slopeBand); }