public override void EndSession() { base.EndSession(); _xs = null; _ys = null; _refSB_Cal_Coefficients = null; _prelaunch_Nonlinear_Coefficients = null; _emissive_Radiance_Scales = null; _emissive_Radiance_Offsets = null; if (_outLdfDriver != null) { _outLdfDriver.Dispose(); _outLdfDriver = null; } _geoDataProvider = null; }
public override void EndSession() { base.EndSession(); _xs = null; _ys = null; _refSB_Coeff = null; _emissive_Radiance_Coeff = null; _emmisive_BT_Coefficients = null; if (_solarZenithCacheRaster != null) { _solarZenithCacheRaster.Dispose(); _solarZenithCacheRaster = null; } if (_outLdfDriver != null) { _outLdfDriver.Dispose(); _outLdfDriver = null; } }
public override void EndSession() { base.EndSession(); _xs = null; _ys = null; _vir_Cal_Coeff = null; if (_solarZenithCacheRaster != null) { _solarZenithCacheRaster.Dispose(); _solarZenithCacheRaster = null; } if (_outLdfDriver != null) { _outLdfDriver.Dispose(); _outLdfDriver = null; } if (_longitudeBand != null) { _longitudeBand.Dispose(); _longitudeBand = null; } if (_latitudeBand != null) { _latitudeBand.Dispose(); _latitudeBand = null; } if (_latitudeRaster != null) { _latitudeRaster.Dispose(); _latitudeRaster = null; } if (_longitudeRaster != null) { _longitudeRaster.Dispose(); _longitudeRaster = null; } }
private string ExtractFile(string filename, int bandIndex, PrjEnvelope env, string regionNam, string outdir) { string projectionType = null; string dstFileName = null; IRasterDataProvider prd = GeoDataDriver.Open(filename) as IRasterDataProvider; double dminx = env.MinX, dmax = env.MaxX, dminy = env.MinY, dmaxy = env.MaxY; int xoffset = (int)(Math.Round((dminx - prd.CoordEnvelope.MinX) / prd.ResolutionX)); int yoffset = (int)(Math.Round((prd.CoordEnvelope.MaxY - dmaxy) / prd.ResolutionY)); if (xoffset < 0) { xoffset = 0; } if (yoffset < 0) { yoffset = 0; } //int yoffset = (int)(Math.Round(dminy - prd.CoordEnvelope.MinY) / prd.ResolutionY); int width = (int)(Math.Round((env.MaxX - env.MinX) / prd.ResolutionX)); int height = (int)(Math.Round((env.MaxY - env.MinY) / prd.ResolutionY)); if (xoffset < 0 || yoffset < 0 || width <= 0 || height <= 0) { MessageBox.Show("文件:" + filename + "小于指定的提取范围"); return(null); } float tResolutionX; float tResolutionY; tResolutionX = Convert.ToSingle(prd.ResolutionX); tResolutionY = Convert.ToSingle(prd.ResolutionY); string[] optionString = new string[] { "INTERLEAVE=BSQ", "VERSION=LDF", "WITHHDR=TRUE", "SPATIALREF=" + projectionType, "MAPINFO={" + 1 + "," + 1 + "}:{" + dminx + "," + dmaxy + "}:{" + tResolutionX + "," + tResolutionY + "}" }; enumDataType dataType = prd.DataType; if (!Directory.Exists(outdir)) { Directory.CreateDirectory(outdir); } dstFileName = Path.Combine(outdir, Path.GetFileName(filename).Replace("China", regionNam));// +"\\" + Path.GetFileNameWithoutExtension(filename) + "_" + regionNam + ".dat"; if (File.Exists(dstFileName)) { return(dstFileName); } IRasterDataDriver dataDriver = GeoDataDriver.GetDriverByName("MEM") as IRasterDataDriver; IRasterDataProvider dstRaster = dataDriver.Create(dstFileName, width, height, 1, dataType, optionString); float[] buffer = new float[width * height]; unsafe { fixed(float *ptr = buffer) { IntPtr bufferPtr = new IntPtr(ptr); prd.GetRasterBand(bandIndex + 1).Read(xoffset, yoffset, width, height, bufferPtr, dataType, width, height); fixed(float *wptr = buffer) { IntPtr newBuffer = new IntPtr(wptr); dstRaster.GetRasterBand(1).Write(0, 0, width, height, newBuffer, dataType, width, height); } } } if (prd != null) { prd.Dispose(); } if (dstRaster != null) { dstRaster.Dispose(); } dataDriver.Dispose(); return(dstFileName); }