private void CheckIs0250(IRasterDataProvider srcRaster) { try { IBandProvider band = srcRaster.BandProvider; Dictionary <string, string> filaAttrs = band.GetAttributes(); if (filaAttrs == null || !filaAttrs.ContainsKey("File Alias Name")) { throw new Exception("不能确认为合法的MERSI轨道数据,尝试获取文件属性File Alias Name的值为空"); } string fileAliasName = filaAttrs["File Alias Name"]; if (string.IsNullOrWhiteSpace(fileAliasName)) { throw new Exception("不能确认为合法的MERSI轨道数据,尝试获取文件属性File Alias Name的值为空"); } else if (fileAliasName == "MERSI_1KM_L1") { _dataType = "1KM"; } else if (fileAliasName == "MERSI_QKM_L1" || fileAliasName == "MERSI_250M_L1") { _dataType = "QKM"; } else { throw new Exception("不能确认为合法的MERSI轨道数据,文件属性File Alias Name的值为[" + fileAliasName + "]支持的是MERSI_1KM_L1或者MERSI_QKM_L1"); } } catch (Exception ex) { throw new Exception("不能确认为合法的MERSI轨道数据" + ex.Message, ex.InnerException); } }
//读取定位信息(经纬度数据集) private void ReadLongitudeLatitude(IRasterDataProvider srcRaster, out double[] longitudes, out double[] latitudes) { IBandProvider srcbandpro = srcRaster.BandProvider as IBandProvider; { Size srSize = new System.Drawing.Size(srcRaster.Width, srcRaster.Height); longitudes = new Double[srcRaster.Width * srcRaster.Height]; latitudes = new Double[srcRaster.Width * srcRaster.Height]; using (IRasterBand lonsBand = srcbandpro.GetBands(Longitude)[0]) { using (IRasterBand latBand = srcbandpro.GetBands(Latitude)[0]) { unsafe { fixed(Double *ptrLong = longitudes) fixed(Double * ptrLat = latitudes) { { IntPtr bufferPtrLat = new IntPtr(ptrLat); IntPtr bufferPtrLong = new IntPtr(ptrLong); latBand.Read(0, 0, srSize.Width, srSize.Height, bufferPtrLat, enumDataType.Double, srSize.Width, srSize.Height); lonsBand.Read(0, 0, srSize.Width, srSize.Height, bufferPtrLong, enumDataType.Double, srSize.Width, srSize.Height); } } } } } } }
protected override void ReadLocations(IRasterDataProvider srcRaster, out double[] longitudes, out double[] latitudes, out Size locationSize) { try { IBandProvider srcbandpro = srcRaster.BandProvider as IBandProvider; { locationSize = new Size(srcRaster.Width, srcRaster.Height); longitudes = new Double[srcRaster.Width * srcRaster.Height]; latitudes = new Double[srcRaster.Width * srcRaster.Height]; using (IRasterBand lonBand = srcbandpro.GetBands(Longitude)[0]) { using (IRasterBand latBand = srcbandpro.GetBands(Latitude)[0]) { unsafe { fixed(Double *ptrLong = longitudes) fixed(Double * ptrLat = latitudes) { { IntPtr bufferPtrLat = new IntPtr(ptrLat); IntPtr bufferPtrLong = new IntPtr(ptrLong); latBand.Read(0, 0, locationSize.Width, locationSize.Height, bufferPtrLat, enumDataType.Double, locationSize.Width, locationSize.Height); lonBand.Read(0, 0, locationSize.Width, locationSize.Height, bufferPtrLong, enumDataType.Double, locationSize.Width, locationSize.Height); } } } } } } } catch (Exception ex) { throw new Exception("读取经纬度数据集失败:" + ex.Message, ex); } }
private void SetDefaultPara(string filename) { ProParas.SrcRaster = GeoDataDriver.Open(_fileNames[0]) as IRasterDataProvider; IBandProvider bandprovider = ProParas.SrcRaster.BandProvider; Dictionary <string, string> _fileAttrs = bandprovider.GetAttributes(); _fileAttrs.TryGetValue("File Alias Name", out _sensorName); ucSelectBands.InitTreeView(ProParas.SrcRaster); ucSelectBands.AddAll(); SetBandsInfo(); switch (_sensorName) { case "VIRR_L1": ProParas.VirrPrjSetting = new FY3_VIRR_PrjSettings(); ProParas.VirrPrjSetting.OutPathAndFileName = _fileNames[0] + "_WHOLE.ldf"; //_WHOLE_LW. //_DXX_LW. //_EF_LW. ProParas.VirrPrjSetting.OutResolutionX = 0.01F; ProParas.VirrPrjSetting.OutResolutionY = 0.01F; ProParas.VirrPrjSetting.OutFormat = "LDF"; ProParas.VirrPrjSetting.OutEnvelope = null; ucSelectBands.InitTreeView(ProParas.SrcRaster); ucSelectBands.AddAll(); //ProParas.VirrPrjSetting.BandMapTable = ucSelectBands.GetBandMapList(); break; } }
private void ReadySolarZenithArgsToFile(IRasterDataProvider srcRaster) { if (srcRaster == null) { throw new ArgumentNullException("srcRaster", "获取太阳天顶角数据失败"); } try { IBandProvider srcbandpro = srcRaster.BandProvider as IBandProvider; Size srcSize = new System.Drawing.Size(srcRaster.Width, srcRaster.Height); short[] readSolarZenithData = ReadDataSetToInt16(srcbandpro, srcSize, SolarZenith, 0); int length = srcRaster.Width * srcRaster.Height; float[] saveSolarZenithData = new float[length]; Parallel.For(0, length, index => { if (readSolarZenithData[index] > 0 && readSolarZenithData[index] < 18000) { saveSolarZenithData[index] = (float)(10.0f / Math.Cos(readSolarZenithData[index] * DEG_TO_RAD_P100)); } else { saveSolarZenithData[index] = 0; } }); _solarZenithCacheRaster = WriteData(saveSolarZenithData, _szDataFilename, srcSize.Width, srcSize.Height); saveSolarZenithData = null; readSolarZenithData = null; } catch (Exception ex) { throw new Exception("获取太阳天顶角数据失败", ex.InnerException); } }
//准备[太阳高度角订正]参数,目前还没有太阳高度角订正的公式。 private void ReadySolarZenithArgs(IRasterDataProvider srcRaster) { IBandProvider bandPrd = srcRaster.BandProvider; IRasterBand[] bands = bandPrd.GetBands("SolarZenith"); if (bands == null || bands.Length == 0 || bands[0] == null) { throw new Exception("读取Noaa 1BD太阳天顶角失败:无法获取到SolarZenith波段信息");//读取天顶角数值 } try { using (IRasterBand band = bands[0]) { double[] data = new double[band.Width * band.Height]; unsafe { fixed(Double *ptr = data) { IntPtr bufferPtr = new IntPtr(ptr); band.Write(0, 0, band.Width, band.Height, bufferPtr, enumDataType.Double, band.Width, band.Height); } } } } catch (Exception ex) { throw new Exception("读取Noaa 1BD太阳天顶角失败:" + ex.Message, ex); } }
private Int16[] ReadBandByNameToInt16(IRasterDataProvider srcRaster, string bandName) { IBandProvider bandPrd = srcRaster.BandProvider; IRasterBand[] bands = bandPrd.GetBands(bandName); if (bands == null || bands.Length == 0 || bands[0] == null) { throw new Exception("读取波段" + bandName + "失败:无法获取该通道信息"); } try { using (IRasterBand band = bands[0]) { Int16[] data = new Int16[band.Width * band.Height]; unsafe { fixed(Int16 *ptr = data) { IntPtr bufferPtr = new IntPtr(ptr); band.Read(0, 0, band.Width, band.Height, bufferPtr, enumDataType.Int16, band.Width, band.Height); } } return(data); } } catch (Exception ex) { throw new Exception("读取波段" + bandName + "失败:" + ex.Message, ex); } }
private void ReadLatLong(IRasterDataProvider srcRaster, out double[] longitudes, out double[] latitudes) { try { IBandProvider srcbandpro = srcRaster.BandProvider as IBandProvider; { Size srSize = new System.Drawing.Size(srcRaster.Width, srcRaster.Height); longitudes = new Double[srcRaster.Width * srcRaster.Height]; latitudes = new Double[srcRaster.Width * srcRaster.Height]; using (IRasterBand lonBand = srcbandpro.GetBands("Longitude")[0]) { using (IRasterBand latBand = srcbandpro.GetBands("Latitude")[0]) { unsafe { fixed(Double *ptrLong = longitudes) fixed(Double * ptrLat = latitudes) { { IntPtr bufferPtrLat = new IntPtr(ptrLat); IntPtr bufferPtrLong = new IntPtr(ptrLong); latBand.Read(0, 0, srSize.Width, srSize.Height, bufferPtrLat, enumDataType.Double, srSize.Width, srSize.Height); lonBand.Read(0, 0, srSize.Width, srSize.Height, bufferPtrLong, enumDataType.Double, srSize.Width, srSize.Height); } } } } } } } catch (Exception ex) { throw new Exception("获取经纬度数据集失败:" + ex.Message, ex); } }
private static bool OutputL1FileByOne(string hdfFile, string outDir, ref string error) { string L1GBALDataSetsStr = GetL1GBALDataset(false); IRasterDataProvider srcPrd = HDF5Driver.Open(hdfFile, enumDataProviderAccess.ReadOnly, new string[] { L1GBALDataSetsStr }) as IRasterDataProvider; if (srcPrd.BandCount == 0) { srcPrd.Dispose(); L1GBALDataSetsStr = GetL1GBALDataset(true); srcPrd = HDF5Driver.Open(hdfFile, enumDataProviderAccess.ReadOnly, new string[] { L1GBALDataSetsStr }) as IRasterDataProvider; } float[] data = null; float[] lon = null; float[] lat = null; string outDirBase = outDir + "\\L1GBAL\\"; Size srSize = Size.Empty; try { GetBandData(srcPrd, srcPrd.BandCount - 1, ref lon, ref srSize); GetBandData(srcPrd, srcPrd.BandCount, ref lat, ref srSize); for (int bandNo = 1; bandNo <= srcPrd.BandCount - 2; bandNo++) { IBandProvider srcbandpro = srcPrd.BandProvider as IBandProvider; { IRasterBand latBand = srcPrd.GetRasterBand(bandNo); { srSize = new Size(latBand.Width, latBand.Height); data = new float[srSize.Width * srSize.Height]; unsafe { fixed(float *ptrLat = data) { IntPtr bufferPtrLat = new IntPtr(ptrLat); latBand.Read(0, 0, srSize.Width, srSize.Height, bufferPtrLat, enumDataType.Float, srSize.Width, srSize.Height); } } } string outFilename = "band_" + bandNo + ".txt"; WriteL1GBALFile(outDirBase + Path.GetFileNameWithoutExtension(hdfFile) + "\\", outFilename, data, lon, lat, srSize); } } } catch (Exception ex) { error += hdfFile + ": " + ex.Message + "\n"; return(false); } finally { data = null; srcPrd.Dispose(); GC.SuppressFinalize(false); } return(true); }
private void GetDataType() { _bandProvider = _provider.BandProvider; _fileAttrs = _bandProvider.GetAttributes(); _fileAttrs.TryGetValue(GETALIASNAME, out _sensorName); _xElemRoot = XElement.Load(XMLFILEPATH, LoadOptions.None); IEnumerable <XElement> items = _xElemRoot.Descendants("File"); CompareType(items); }
private void ReadyRadiationArgs(IRasterDataProvider srcRaster, string dataSetName) { if (srcRaster == null) { throw new ArgumentNullException("srcRaster", "获取亮温转换参数失败"); } if (dataSetName == null) { throw new ArgumentNullException("dataSetName", "获取亮温转换参数失败"); } try { IBandProvider srcbandpro = srcRaster.BandProvider as IBandProvider; switch (dataSetName) { case "EV_1KM_RefSB": _radiance_Scales = ReadDataSetAttrToFloat(srcbandpro, "EV_1KM_RefSB", "reflectance_scales", 15); _radiance_Offsets = ReadDataSetAttrToFloat(srcbandpro, "EV_1KM_RefSB", "reflectance_offsets", 15); break; case "EV_250_Aggr1km_RefSB": _radiance_Scales = ReadDataSetAttrToFloat(srcbandpro, "EV_250_Aggr1km_RefSB", "reflectance_scales", 2); _radiance_Offsets = ReadDataSetAttrToFloat(srcbandpro, "EV_250_Aggr1km_RefSB", "reflectance_offsets", 2); break; case "EV_500_Aggr1km_RefSB": _radiance_Scales = ReadDataSetAttrToFloat(srcbandpro, "EV_500_Aggr1km_RefSB", "reflectance_scales", 5); _radiance_Offsets = ReadDataSetAttrToFloat(srcbandpro, "EV_500_Aggr1km_RefSB", "reflectance_offsets", 5); break; case "EV_1KM_Emissive": //热红外satellite Terra (EOS AM-1) Aqua (EOS PM-1) _radiance_Scales = ReadDataSetAttrToFloat(srcbandpro, "EV_1KM_Emissive", "radiance_scales", 16); _radiance_Offsets = ReadDataSetAttrToFloat(srcbandpro, "EV_1KM_Emissive", "radiance_offsets", 16); if (_fileAliasName == "Terra") { _v = new float[] { 3788.3F, 3992.2F, 3972.0F, 4056.7F, 4473.2F, 4545.4F, 6770.5F, 7342.9F, 8528.7F, 9734.1F, 11018.9F, 12032.1F, 13365.0F, 13683.3F, 13925.2F, 14195.6F }; } else if (_fileAliasName == "Aqua") { _v = new float[] { 3780.2F, 3981.8F, 3972.0F, 4061.6F, 4448.3F, 4526.3F, 6786.8F, 7349.3F, 8555.3F, 9723.7F, 11026.2F, 12042.3F, 13364.7F, 13685.9F, 13913.2F, 14215.2F }; } break; default: break; } } catch (Exception ex) { throw new Exception("获取亮温转换参数失败", ex.InnerException); } }
private void TestGDALRead() { string dsFile = ""; dsFile = "HDF4_SDS:UNKNOWN:\"D:\\masData\\MODIS\\TERRA_2010_03_25_03_09_GZ.MOD03.hdf\":23"; dsFile = "D:\\masData\\MODIS\\TERRA_2010_03_25_03_09_GZ.MOD021KM.hdf"; IRasterDataProvider srcRaster = GeoDataDriver.Open(dsFile) as IRasterDataProvider; IBandProvider srcbandpro = srcRaster.BandProvider; IDictionary <string, string> dsAtts = srcbandpro.GetDatasetAttributes("EV_1KM_RefSB");//reflectance_scales dsAtts = srcbandpro.GetAttributes(); }
private void ReadLocations(IRasterDataProvider srcRaster, out IRasterBand longitudeBand, out IRasterBand latitudeBand) { IBandProvider srcbandpro = srcRaster.BandProvider as IBandProvider; IRasterBand[] lonsBands = srcbandpro.GetBands("Longitude"); IRasterBand[] latBands = srcbandpro.GetBands("Latitude"); if (lonsBands == null || latBands == null || lonsBands.Length == 0 || latBands.Length == 0 || lonsBands[0] == null || latBands[0] == null) { throw new Exception("获取经纬度数据失败"); } longitudeBand = lonsBands[0]; latitudeBand = latBands[0]; }
private void ReadyRadiationArgs(IRasterDataProvider srcRaster) { if (srcRaster == null) { throw new ArgumentNullException("srcRaster", "获取亮温转换参数失败:参数srcRaster为空"); } try { IBandProvider srcbandpro = srcRaster.BandProvider as IBandProvider; _vir_Cal_Coeff = ReadFileAttributeToFloat(srcbandpro, VIR_Cal_Coeff, 57); } catch (Exception ex) { throw new Exception("获取亮温转换参数失败:" + ex.Message, ex.InnerException); } }
//准备[太阳高度角订正]参数,目前还没有太阳高度角订正的公式。 private void ReadySolarZenithArgs(IRasterDataProvider srcRaster) { if (srcRaster == null) { throw new ArgumentNullException("srcRaster", "获取太阳天顶角数据失败"); } try { IBandProvider srcbandpro = srcRaster.BandProvider as IBandProvider; Size srcSize = new System.Drawing.Size(srcRaster.Width, srcRaster.Height); _solarZenithData = ReadDataSetToInt16(srcbandpro, srcSize, SolarZenith, 0); } catch (Exception ex) { throw new Exception("获取太阳天顶角数据失败", ex.InnerException); } }
private float[] ReadDataSetToSingle(IBandProvider srcbandpro, Size srcSize, string dataSetName, int bandIndex) { Single[] data = new Single[srcSize.Width * srcSize.Height]; using (IRasterBand rasterBand = srcbandpro.GetBands(dataSetName)[0]) { unsafe { fixed(Single *ptr = data) { IntPtr bufferPtr = new IntPtr(ptr); rasterBand.Read(0, 0, srcSize.Width, srcSize.Height, bufferPtr, enumDataType.Float, srcSize.Width, srcSize.Height); } } } return(data); }
private IRasterBand[] TryCreateRasterDataBands(IRasterDataProvider srcRaster, FY3L2L3FilePrjSettings prjSettings, Action <int, string> progressCallback) { IBandProvider srcbandpro = srcRaster.BandProvider as IBandProvider; int count = srcRaster.BandCount; List <IRasterBand> rasterBands = new List <IRasterBand>(); for (int i = 0; i < count; i++) { if (progressCallback != null) { progressCallback(_readyProgress++, "准备第" + i + "个输入数据通道"); } IRasterBand band = srcRaster.GetRasterBand(i + 1); rasterBands.Add(band); } return(rasterBands.ToArray()); }
unsafe public void SetBandProvider() { string fname = "d:\\0111d2.n16.1bd"; IRasterDataProvider prd = GeoDataDriver.Open(fname) as IRasterDataProvider; IBandProvider bp = prd.BandProvider; IRasterBand[] rb = bp.GetBands("Longitude"); Console.WriteLine(rb); Assert.NotNull(rb); UInt16[] buffer = new UInt16[4]; fixed(UInt16 *ptr = buffer) { IntPtr bufferPtr = new IntPtr(ptr); rb[0].Read(0, 0, 2, 2, bufferPtr, enumDataType.UInt16, 2, 2); } }
private Int16[] ReadDataSetToInt16(IBandProvider srcbandpro, Size srcSize, string dataSetName, int bandIndex) { Int16[] data = new Int16[srcSize.Width * srcSize.Height]; IRasterBand[] rasterBands = srcbandpro.GetBands(dataSetName); using (IRasterBand rasterBand = rasterBands[0]) { unsafe { fixed(Int16 *ptr = data) { IntPtr bufferPtr = new IntPtr(ptr); rasterBand.Read(0, 0, srcSize.Width, srcSize.Height, bufferPtr, enumDataType.Int16, srcSize.Width, srcSize.Height); } } } return(data); }
/// <summary> 读取通道值</summary> private void ReadBandData(UInt16[] bandData, IRasterDataProvider srcRaster, string bandName, int bandNumber, Size srcSize) { IBandProvider srcbandpro = srcRaster.BandProvider as IBandProvider; { using (IRasterBand latBand = srcbandpro.GetBands(bandName)[bandNumber]) { unsafe { fixed(UInt16 *ptr = bandData) { IntPtr bufferptr = new IntPtr(ptr); latBand.Read(0, 0, srcSize.Width, srcSize.Height, bufferptr, enumDataType.UInt16, srcSize.Width, srcSize.Height); } } } } }
private IRasterBand[] TryCreateRasterDataBands(IRasterDataProvider srcRaster, FY3_MERSI_PrjSettings fy3prjSettings, Action <int, string> progressCallback) { IBandProvider srcbandpro = srcRaster.BandProvider as IBandProvider; List <IRasterBand> rasterBands = new List <IRasterBand>(); for (int i = 0; i < _prjBands.Length; i++) { if (progressCallback != null) { progressCallback(_readyProgress++, "准备第" + i + "个输入数据通道"); } PrjBand bandMap = _prjBands[i]; IRasterBand[] latBands = srcbandpro.GetBands(bandMap.DataSetName); IRasterBand band = latBands[bandMap.DataSetIndex]; rasterBands.Add(band); } return(rasterBands.ToArray()); }
private void ReadyRadiationArgs(IRasterDataProvider srcRaster) { if (srcRaster == null) { throw new ArgumentNullException("srcRaster", "获取亮温转换参数失败:参数srcRaster为空"); } try { IBandProvider srcbandpro = srcRaster.BandProvider as IBandProvider; //这里和之前FY3B的数据有区别,FY3C的此参数存在数据集VIS_Cal_Coeff中,19*3。band_name = 1-4, 6-20 //_vir_Cal_Coeff = ReadFileAttributeToFloat(srcbandpro, VIR_Cal_Coeff, 57); Size visSize = new Size(3, 19); _vir_Cal_Coeff = ReadDataSetToSingle(srcbandpro, visSize, "Calibration/VIS_Cal_Coeff", 0); } catch (Exception ex) { throw new Exception("获取亮温转换参数失败:" + ex.Message, ex.InnerException); } }
/// <summary> /// 会出现三个值D、N、M /// </summary> /// <param name="fileRaster"></param> /// <returns></returns> private string DayOrNight(IRasterDataProvider fileRaster) { try { string v = ""; IBandProvider band = fileRaster.BandProvider; Dictionary <string, string> filaAttrs = band.GetAttributes(); if (filaAttrs.ContainsKey("Day Or Night Flag")) //VIRR:D MERSI:Day { v = filaAttrs["Day Or Night Flag"]; } else if (filaAttrs.ContainsKey("DAYNIGHTFLAG")) //MODIS:Day { v = filaAttrs["DAYNIGHTFLAG"]; } else { v = ""; } if (v == "") { return("X"); } if (Days.Contains(v)) { return("D"); } if (Nights.Contains(v)) { return("N"); } if (Ms.Contains(v)) { return("M"); } return("X"); } catch { return("X"); } }
private float[] ReadFileAttributeToFloat(IBandProvider srcbandpro, string AttrName, int length) { float[] value = new float[length]; Dictionary <string, string> dsAtts = srcbandpro.GetAttributes(); string refSbCalStr = dsAtts[AttrName]; string[] refSbCals = refSbCalStr.Split(','); if (refSbCals.Length >= length) { for (int i = 0; i < length; i++) { value[i] = float.Parse(refSbCals[i]); } return(value); } else { return(null); } }
private static void GetBandData(IRasterDataProvider srcPrd, int bandNo, ref float[] data, ref Size srSize) { IBandProvider srcbandpro = srcPrd.BandProvider as IBandProvider; { IRasterBand latBand = srcPrd.GetRasterBand(bandNo); { srSize = new Size(latBand.Width, latBand.Height); data = new float[srSize.Width * srSize.Height]; unsafe { fixed(float *ptrLat = data) { IntPtr bufferPtrLat = new IntPtr(ptrLat); latBand.Read(0, 0, srSize.Width, srSize.Height, bufferPtrLat, enumDataType.Float, srSize.Width, srSize.Height); } } } } }
private void ReadyRadiationArgs(IRasterDataProvider srcRaster) { if (srcRaster == null) { throw new ArgumentNullException("srcRaster", "获取亮温转换参数失败:参数srcRaster为空"); } try { IBandProvider srcbandpro = srcRaster.BandProvider as IBandProvider; _refSB_Cal_Coefficients = ReadFileAttributeToFloat(srcbandpro, RefSB_Cal_Coefficients, 14); _prelaunch_Nonlinear_Coefficients = ReadFileAttributeToFloat(srcbandpro, Prelaunch_Nonlinear_Coefficients, 9); Size srcSize = new Size(srcRaster.Width, srcRaster.Height); _emissive_Radiance_Scales = ReadDataSetToSingle(srcbandpro, new Size(3, srcSize.Height), Emissive_Radiance_Scales, 0); _emissive_Radiance_Offsets = ReadDataSetToSingle(srcbandpro, new Size(3, srcSize.Height), Emissive_Radiance_Offsets, 0); } catch (Exception ex) { throw new Exception("获取亮温转换参数失败:" + ex.Message, ex.InnerException); } }
public static IBandProvider GetBandProvider(string fname, byte[] header1024, Access access, IRasterDataProvider provider, Dictionary <string, string> datasetNames) { IBandProvider prd = null; if (!IsLoadedBandProviders) { RegisteredBandProviders = TryLoadRegisteredBandProviders(); } prd = GetMatchedBandProvider(fname, header1024, RegisteredBandProviders, datasetNames); if (prd != null) { DataIdentify dataIdentify = prd.DataIdentify; prd.DataIdentify = new DataIdentify(); prd = Activator.CreateInstance(prd.GetType()) as IBandProvider; prd.Init(fname, access == Access.GA_ReadOnly ? enumDataProviderAccess.ReadOnly : enumDataProviderAccess.Update, provider); prd.DataIdentify = dataIdentify; } return(prd); }
public void TestReadHDF()//持续运行多次后,自动退出 { IRasterDataProvider srcPrd = GetReader(); MessageBox.Show("创建provider成功"); try { for (int i = 0; i < 10; i++) { IBandProvider srcbandpro = srcPrd.BandProvider as IBandProvider; { IRasterBand[] latBands = srcbandpro.GetBands("EV_1KM_RefSB"); IRasterBand latBand = latBands[0]; { Size srSize = new Size(latBand.Width / 2, latBand.Height / 2); UInt16[] lats = new UInt16[srSize.Width * srSize.Height]; unsafe { fixed(UInt16 *ptrLat = lats) { IntPtr bufferPtrLat = new IntPtr(ptrLat); latBand.Read(0, 0, srSize.Width, srSize.Height, bufferPtrLat, enumDataType.UInt16, srSize.Width, srSize.Height); } } } } MessageBox.Show("读取通道数据成功"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { srcPrd.Dispose(); GC.SuppressFinalize(false); } }
private void ReadDnIS(IRasterDataProvider srcImgRaster, string dsName) { if (srcImgRaster == null) { throw new ArgumentNullException("srcRaster", "获取亮温转换参数失败:参数srcRaster为空"); } if (dsName == null) { throw new ArgumentNullException("dataSetName", "获取亮温转换参数失败:参数srcRaster为空"); } try { IBandProvider srcbandpro = srcImgRaster.BandProvider as IBandProvider; int count = srcbandpro.GetBands(dsName).Length; _dsIntercept = ReadDataSetAttrToFloat(srcbandpro, dsName, "Intercept", count); _dsSlope = ReadDataSetAttrToFloat(srcbandpro, dsName, "Slope", count); } catch (Exception ex) { throw new Exception("获取亮温转换参数失败:" + ex.Message, ex.InnerException); } }
//用于可见光太阳高度角订正,准备[太阳高度角订正]参数,目前还没有太阳高度角订正的公式。 private void ReadySolarZenithArgs(IRasterDataProvider srcRaster) { if (srcRaster == null) { throw new ArgumentNullException("srcRaster", "获取太阳天顶角数据失败"); } try { IBandProvider srcbandpro = srcRaster.BandProvider as IBandProvider; short[] solarZenithDataS = ReadDataSetToInt16(srcbandpro, SolarZenith, 0); int length = solarZenithDataS.Length; _solarZenithData = new double[length]; Parallel.For(0, length, i => { _solarZenithData[i] = 1.0 / Math.Cos(solarZenithDataS[i] * DEG_TO_RAD_P100); }); } catch (Exception ex) { throw new Exception("获取太阳天顶角数据失败", ex.InnerException); } }