//[SetUp] public void DataReady(Action <int, string> progressCallback) { try { ///等经纬度投影 dstFilename = @"D:\mas数据\Mersi\fy3_Block.ldf"; dstSpatialRef = SpatialReferenceFactory.GetSpatialReferenceByPrjFile("WGS 1984.prj");// srcFilename = @"D:\mas数据\Mersi\FY3A_MERSI_GBAL_L1_20110501_0250_1000M_MS.HDF"; dstEnvelope = PrjEnvelope.CreateByCenter(116.890377, 27.7621965, 33.49, 21.53); srcRaster = GeoDataDriver.Open(srcFilename) as IRasterDataProvider; prjSetting = new FY3_MERSI_PrjSettings(); //prjSetting.OutResolutionX = 0.01F; //prjSetting.OutResolutionY = 0.01F; prjSetting.OutPathAndFileName = dstFilename; prjSetting.OutFormat = "LDF"; //prjSetting.OutEnvelope = dstEnvelope; //prjSetting.BandMapTable = bandmapList; prjSetting.IsRadiation = true; _progressCallback = progressCallback; } catch (Exception ex) { Console.WriteLine(ex.Message); MessageBox.Show(ex.Message); } }
//[SetUp] public void DataReady(Action <int, string> progressCallback) { ///等经纬度投影 dstFilename = @"D:\mas数据\MODIS\TERRA_2010_03_25_03_09_GZ.MOD02HKM.ldf"; dstSpatialRef = SpatialReferenceFactory.GetSpatialReferenceByPrjFile("WGS 1984.prj"); // srcFilename = @"D:\mas数据\MODIS\TERRA_2010_03_25_03_09_GZ.MOD02HKM.HDF"; dstEnvelope = PrjEnvelope.CreateByCenter(110, 32, 5, 5); // string secondFile = @"D:\mas数据\MODIS\TERRA_2010_03_25_03_09_GZ.MOD03.HDF"; IRasterDataProvider secondFileRaster = GeoDataDriver.Open(secondFile) as IRasterDataProvider; srcRaster = GeoDataDriver.Open(srcFilename) as IRasterDataProvider; //List<BandMap> bandmapList = new List<BandMap>(); prjSetting = new EOS_MODIS_PrjSettings(); prjSetting.OutResolutionX = 0.0025F; prjSetting.OutResolutionY = 0.0025F; prjSetting.OutPathAndFileName = dstFilename; prjSetting.OutFormat = "LDF"; //prjSetting.OutEnvelope = dstEnvelope; //prjSetting.BandMapTable = bandmapList; //prjSetting.IsRadiation = false; prjSetting.SecondaryOrbitRaster = null; prjSetting.LocationFile = secondFileRaster; _progressCallback = progressCallback; }
public GeoRegionEditCenter() { InitializeComponent(); _error = new ErrorProvider(); _spatialRef = SpatialReference.GetDefault(); _resolutionX = 0.01f; _resolutionY = 0.01f; _center = new PrjPoint(0d, 0d); _size = new System.Drawing.Size(1024, 1024); _envelope = PrjEnvelope.CreateByCenter(_center.X, _center.Y, 0.01d * _size.Width, 0.01d * _size.Height); }
private FilePrjSettings GetPrjSetting(IRasterDataProvider srcRaster) { string dstFilename = @"D:\masData\noaa_1bd\testtt.ldf"; PrjEnvelope dstEnvelope = PrjEnvelope.CreateByCenter(78.621416, 32.189639, 36.00, 26.00); NOAA_PrjSettings prjSetting = new NOAA_PrjSettings(); prjSetting.OutPathAndFileName = dstFilename; //必填 //prjSetting.OutResolutionX = 1000F; //default //prjSetting.OutResolutionY = 1000F; //default //prjSetting.OutFormat = "LDF"; //default //prjSetting.OutEnvelope = dstEnvelope; //default prjSetting.IsRadiation = true; //default true prjSetting.IsSolarZenith = true; return(prjSetting); }
private PrjEnvelope GetPrjEnvelopeFromCenter(float resolutionX, float resolutionY) { Size size = ucPrjEnvelopes1.PixelSize; PrjPoint center = ucPrjEnvelopes1.CenterLongLat; double[] xs = new double[] { center.X }; double[] ys = new double[] { center.Y }; using (IProjectionTransform tran = ProjectionTransformFactory.GetProjectionTransform(SpatialReference.GetDefault(), _dstSpatialRef)) { tran.Transform(xs, ys); } PrjEnvelope env = PrjEnvelope.CreateByCenter(xs[0], ys[0], resolutionX * size.Width, resolutionY * size.Height); return(env); }
private FY3_VIRR_PrjSettings GetPrjSetting(IRasterDataProvider srcRaster) { string dstFilename = @"D:\fy3VIRR_Block.ldf"; PrjEnvelope dstEnvelope = PrjEnvelope.CreateByCenter(78.621416, 32.189639, 36.00, 26.00); FY3_VIRR_PrjSettings prjSetting = new FY3_VIRR_PrjSettings(); prjSetting.OutPathAndFileName = dstFilename; //必填 //prjSetting.OutResolutionX = 1000F; //default //prjSetting.OutResolutionY = 1000F; //default //prjSetting.OutFormat = "LDF"; //default //prjSetting.OutEnvelope = dstEnvelope; //default //prjSetting.BandMapTable = bandmapList;//default prjSetting.IsRadiation = true; //default true prjSetting.IsSolarZenith = true; //default true return(prjSetting); }
private EOS_MODIS_PrjSettings GetPrjSetting(IRasterDataProvider srcRaster, IRasterDataProvider location) { string dstFilename = @"D:\TERRA_2012_03_16_02_56_GZ.MOD021KM.ldf"; PrjEnvelope dstEnvelope = PrjEnvelope.CreateByCenter(78.621416, 32.189639, 36.00, 26.00); //List<BandMap> bandmapList = new List<BandMap>(); EOS_MODIS_PrjSettings prjSetting = new EOS_MODIS_PrjSettings(); prjSetting.OutPathAndFileName = dstFilename; //必填 prjSetting.LocationFile = location; //经纬度坐标文件,必须指定 //prjSetting.OutResolutionX = 1000F; //default //prjSetting.OutResolutionY = 1000F; //default //prjSetting.OutFormat = "LDF"; //default //prjSetting.OutEnvelope = dstEnvelope; //default //prjSetting.BandMapTable = bandmapList;//default prjSetting.IsRadiation = true; //default true prjSetting.IsSolarZenith = true; return(prjSetting); }
public void btnSure_Click(object sender, EventArgs e) { switch (cmbOutRange.SelectedItem.ToString()) { case "整轨投影": ProParas.PrjSetting.OutEnvelope = null; break; case "按中心点": ProParas.PrjSetting.OutEnvelope = PrjEnvelope.CreateByCenter(Convert.ToDouble(txtCenterX.Text), Convert.ToDouble(txtCenterY.Text), Convert.ToDouble(numerWidth.Value), Convert.ToDouble(numerHeight.Value)); break; case "按四角经纬度": ProParas.PrjSetting.OutEnvelope.MinX = Convert.ToDouble(txtMinX.Text); ProParas.PrjSetting.OutEnvelope.MaxX = Convert.ToDouble(txtMaxX.Text); ProParas.PrjSetting.OutEnvelope.MinY = Convert.ToDouble(txtMinY.Text); ProParas.PrjSetting.OutEnvelope.MaxY = Convert.ToDouble(txtMaxY.Text); break; case "按已定义的输出区域": ProParas.PrjSetting.OutEnvelope = null; break; } switch (cmbProType.SelectedItem.ToString()) { case "等经纬度投影": ProParas.DstSpatialRef = new SpatialReference(new GeographicCoordSystem()); break; case "麦卡托投影": ProParas.DstSpatialRef = SpatialReferenceFactory.GetSpatialReferenceByPrjFile("MASMercator.prj"); break; case "兰勃托投影": ProParas.DstSpatialRef = SpatialReferenceFactory.GetSpatialReferenceByPrjFile("MASLambert.prj"); break; case "极射赤面投影": ProParas.DstSpatialRef = SpatialReferenceFactory.GetSpatialReferenceByPrjFile("MasPolarStere.prj"); break; case "等面积投影": //ProParas.DstSpatialRef = SpatialReferenceFactory.GetSpatialReferenceByPrjFile(""); break; } }
//[SetUp] public void DataReady(Action <int, string> progressCallback) { IRasterDataProvider secondFileRaster = null; try { ///等经纬度投影 dstFilename = @"D:\mas数据\Mersi\fy3Mersi0250_Block.ldf"; dstSpatialRef = SpatialReferenceFactory.GetSpatialReferenceByPrjFile("WGS 1984.prj"); // srcFilename = @"D:\mas数据\Mersi\FY3A_MERSI_GBAL_L1_20110501_0250_0250M_MS.HDF"; dstEnvelope = PrjEnvelope.CreateByCenter(110, 32, 5, 5); // string secondFile = @"D:\mas数据\Mersi\FY3A_MERSI_GBAL_L1_20110501_0250_1000M_MS.HDF"; secondFileRaster = GeoDataDriver.Open(secondFile) as IRasterDataProvider; srcRaster = GeoDataDriver.Open(srcFilename) as IRasterDataProvider; //List<BandMap> bandmapList = new List<BandMap>(); prjSetting = new FY3_MERSI_PrjSettings(); prjSetting.OutResolutionX = 0.0025F; prjSetting.OutResolutionY = 0.0025F; prjSetting.OutPathAndFileName = dstFilename; prjSetting.OutFormat = "LDF"; //prjSetting.OutEnvelope = dstEnvelope; //prjSetting.BandMapTable = bandmapList; //prjSetting.IsRadiation = false; prjSetting.SecondaryOrbitRaster = secondFileRaster; _progressCallback = progressCallback; } catch (Exception ex) { Console.WriteLine(ex.Message); MessageBox.Show(ex.Message); } finally { if (secondFileRaster != null) { secondFileRaster.Dispose(); } } }
private void PrjVIRR(string file) { IRasterDataProvider srcRaster = null; try { PrjEnvelope[] prjEnvelopes = new PrjEnvelope[] { PrjEnvelope.CreateByCenter(100, 30, 10, 10), PrjEnvelope.CreateByCenter(110, 29, 10, 10), PrjEnvelope.CreateByCenter(105, 28, 10, 10), PrjEnvelope.CreateByCenter(105, 27, 10, 10), PrjEnvelope.CreateByCenter(105, 26, 10, 10), PrjEnvelope.CreateByCenter(105, 25, 10, 10), PrjEnvelope.CreateByCenter(105, 24, 10, 10), PrjEnvelope.CreateByCenter(105, 23, 10, 10), PrjEnvelope.CreateByCenter(105, 22, 10, 10), PrjEnvelope.CreateByCenter(105, 21, 10, 10), PrjEnvelope.CreateByCenter(105, 20, 10, 10) }; Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); srcRaster = GetSrcRaster(file); IFileProjector proj = FileProjector.GetFileProjectByName("FY3_VIRR"); proj.BeginSession(srcRaster); for (int i = 0; i < prjEnvelopes.Length; i++) { try { GeoDo.RasterProject.PrjEnvelope prjEnvelope = prjEnvelopes[i]; FY3_VIRR_PrjSettings prjSetting = new FY3_VIRR_PrjSettings(); prjSetting.OutPathAndFileName = GetOutPutFile(file, i); prjSetting.OutEnvelope = prjEnvelope; prjSetting.OutResolutionX = 0.0025F; prjSetting.OutResolutionY = 0.0025F; ISpatialReference dstSpatialRef = SpatialReference.GetDefault(); proj.Project(srcRaster, prjSetting, dstSpatialRef, _progressCallback); stopwatch.Stop(); WriteLine("数据投影{0}ms", stopwatch.ElapsedMilliseconds); this.Text = prjSetting.OutPathAndFileName; } catch (Exception ex) { this.Text = ex.Message; } } proj.EndSession(); stopwatch.Stop(); WriteLine("数据投影{0}ms", stopwatch.ElapsedMilliseconds); } finally { if (srcRaster != null) { if (srcRaster.BandProvider != null) { srcRaster.BandProvider.Dispose(); } srcRaster.Dispose(); } GC.Collect(); } }
/// <summary> /// /// </summary> /// <param name="argument"> /// 格式"*#*"冒号前面部分表示文件名称,冒号后面部分表示所选投影坐标的Wkt格式字符串 /// </param> public override void Execute(string argument) { try { string fileName = ""; string prjString = ""; ISpatialReference proj = null; if (string.IsNullOrWhiteSpace(argument)) { fileName = TryGetFileFromActiveView(); proj = SpatialReference.GetDefault(); } else { MatchCollection matches = Regex.Matches(argument, @"(?<file>[^#]*)#(?<proj>.*)"); fileName = matches[0].Groups["file"].Value; prjString = matches[0].Groups["proj"].Value; if (string.IsNullOrWhiteSpace(fileName) || fileName.ToLower() == "null") { fileName = TryGetFileFromActiveView(); } if (string.IsNullOrWhiteSpace(prjString) || prjString.ToLower() == "null") { proj = SpatialReference.GetDefault(); } else { proj = SpatialReference.FromWkt(prjString, enumWKTSource.EsriPrjFile); } } if (string.IsNullOrWhiteSpace(fileName)) { throw new Exception("无法从参数中解析出文件名:" + argument); } PrjEnvelope envelope = TryGetFirstAOI(); PrjOutArg prjOutArg = ProjectionFactory.GetDefaultArg(fileName); if (prjOutArg == null) { throw new Exception("暂未提供该支持"); } if (envelope == null || envelope.IsEmpty) { envelope = prjOutArg.Envelopes[0] == null ? null : prjOutArg.Envelopes[0].PrjEnvelope; } if (envelope == null) { envelope = PrjEnvelope.CreateByCenter(105, 30, 10, 10); } //根据投影配置文件修改输出文件目录 string outDir = null; if (TryGetOutDirFormConfig(out outDir)) { prjOutArg.OutDirOrFile = outDir; } using (frmPrjEnvelopeSet frmPrjSetArgs = new frmPrjEnvelopeSet()) { using (IRasterDataProvider file = FileHelper.Open(fileName)) { frmPrjSetArgs.SetDefault(file); } frmPrjSetArgs.SetArgs(proj, envelope, prjOutArg.ResolutionX, prjOutArg.ResolutionY, prjOutArg.OutDirOrFile); if (frmPrjSetArgs.ShowDialog() != DialogResult.OK) { return; } prjOutArg = frmPrjSetArgs.PrjOutArg; } Project(fileName, proj, prjOutArg); } catch (Exception ex) { MessageBox.Show(ex.Message, "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); } }