/// <summary> /// 栅格转为面矢量 /// </summary> /// <param name="inFile">输入栅格</param> /// <param name="selectField">选中字段</param> /// <param name="outFile">输出文件</param> public static void RasterToPolygon(string inFile, string selectField, string outFile) { RasterToPolygon rasterToPolygon = new RasterToPolygon { in_raster = inFile, raster_field = selectField, out_polygon_features = outFile }; GeoprocessorHelper.GpExecute(rasterToPolygon); }
public void CanCreateMultiPartPolygons(string file) { var target = new RasterToPolygon(); var p = new GdalRasterProvider(); var raster = p.Open(file); var outShape = new PolygonShapefile {Filename = FileTools.GetTempFileName(".shp")}; target.Execute(raster, outShape, new MockProgressHandler()); FileTools.DeleteShapeFile(outShape.Filename); var mpCount = outShape.Features.Count(t => t.BasicGeometry is MultiPolygon); Assert.That(mpCount > 0); }
public static bool ConvertRasterToPolygon(string inRaster, string outPolygon, out IEnumerable <string> messages) { RasterToPolygon rasterToPolygon = new RasterToPolygon() { in_raster = inRaster, out_polygon_features = outPolygon, simplify = "SIMPLIFY", raster_field = "Value" }; return(RunTool(rasterToPolygon, null, out messages)); }
public void CanCreateMultiPartPolygons(string path) { var target = new RasterToPolygon(); var file = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, path); var p = new GdalRasterProvider(); var raster = p.Open(file); var outShape = new PolygonShapefile {Filename = Path.ChangeExtension(file, ".shp")}; target.Execute(raster, outShape, new MockProgressHandler()); var mpCount = outShape.Features.Count(t => t.BasicGeometry is MultiPolygon); Assert.That(mpCount > 0); }
public void NoMultiPartPolygonsWithConnectionGrid(string rasterFile, string flowDirectionGridFile) { var p = new GdalRasterProvider(); var raster = p.Open(rasterFile); var flowDirectionGrid = p.Open(flowDirectionGridFile); var target = new RasterToPolygon(); var outShape = new PolygonShapefile { Filename = FileTools.GetTempFileName(".shp") }; target.Execute(raster, flowDirectionGrid, outShape, new MockProgressHandler()); FileTools.DeleteShapeFile(outShape.Filename); var mpCount = outShape.Features.Count(t => t.BasicGeometry is MultiPolygon); Assert.That(mpCount == 0); }
public void CanCreateMultiPartPolygons(string file) { var target = new RasterToPolygon(); var p = new GdalRasterProvider(); var raster = p.Open(file); var outShape = new PolygonShapefile { Filename = FileTools.GetTempFileName(".shp") }; target.Execute(raster, outShape, new MockProgressHandler()); FileTools.DeleteShapeFile(outShape.Filename); var mpCount = outShape.Features.Count(t => t.Geometry is MultiPolygon); Assert.That(mpCount > 0); }
public void NoMultiPartPolygonsWithConnectionGrid(string rasterFile, string flowDirectionGridFile) { rasterFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, rasterFile); flowDirectionGridFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, flowDirectionGridFile); var p = new GdalRasterProvider(); var raster = p.Open(rasterFile); var flowDirectionGrid = p.Open(flowDirectionGridFile); var target = new RasterToPolygon(); var outShape = new PolygonShapefile { Filename = Path.ChangeExtension(rasterFile, ".shp") }; target.Execute(raster, flowDirectionGrid, outShape, new MockProgressHandler()); var mpCount = outShape.Features.Count(t => t.BasicGeometry is MultiPolygon); Assert.That(mpCount == 0); }
private void button3_Click(object sender, EventArgs e) { ToggleEndlessProgress.Execute(); circularProgress1.IsRunning = true; #region GP工具的使用 //得到参数 IRasterLayer layer = GetRasterLayer((string)comboBox1.SelectedItem); string field = (string)comboBox2.SelectedItem; string out_polygon = textBox1.Text; string simplify; if (radioButton1.Checked) { simplify = radioButton1.Text; } else { simplify = radioButton2.Text; } //实例化GP工具 Geoprocessor gp = new Geoprocessor(); gp.OverwriteOutput = true; //设置矢量转栅格参数 RasterToPolygon rastertopolygon = new RasterToPolygon(); rastertopolygon.in_raster = layer; rastertopolygon.out_polygon_features = out_polygon; rastertopolygon.raster_field = field; rastertopolygon.simplify = simplify; //执行GP工具 IGeoProcessorResult results = (IGeoProcessorResult)gp.Execute(rastertopolygon, null); #endregion circularProgress1.IsRunning = false; #region 运行完成之后的信息提示窗口 balloonTipFocus.Enabled = true; DevComponents.DotNetBar.Balloon b = new DevComponents.DotNetBar.Balloon(); b.Style = eBallonStyle.Alert; //b.CaptionImage = balloonTipFocus.CaptionImage.Clone() as Image; b.CaptionText = "信息提示"; b.Text = "运行成功!"; b.AlertAnimation = eAlertAnimation.TopToBottom; b.AutoResize(); b.AutoClose = true; b.AutoCloseTimeOut = 4; b.Owner = this; b.Show(button4, false); #endregion }
public void NoMultiPartPolygonsWithConnectionGrid(string rasterFile, string flowDirectionGridFile) { var p = new GdalRasterProvider(); var raster = p.Open(rasterFile); var flowDirectionGrid = p.Open(flowDirectionGridFile); var target = new RasterToPolygon(); var outShape = new PolygonShapefile { Filename = FileTools.GetTempFileName(".shp") }; target.Execute(raster, flowDirectionGrid, outShape, new MockProgressHandler()); FileTools.DeleteShapeFile(outShape.Filename); var mpCount = outShape.Features.Count(t => t.Geometry is MultiPolygon); Assert.That(mpCount == 0); }
private void button3_Click(object sender, EventArgs e) { ToggleEndlessProgress.Execute(); circularProgress1.IsRunning = true; #region GP工具的使用 //得到参数 IRasterLayer layer = GetRasterLayer((string)comboBox1.SelectedItem); string field = (string)comboBox2.SelectedItem; string out_polygon = textBox1.Text; string simplify; if (radioButton1.Checked) { simplify = radioButton1.Text; } else { simplify = radioButton2.Text; } //实例化GP工具 Geoprocessor gp = new Geoprocessor(); gp.OverwriteOutput = true; //设置矢量转栅格参数 RasterToPolygon rastertopolygon = new RasterToPolygon(); rastertopolygon.in_raster = layer; rastertopolygon.out_polygon_features = out_polygon; rastertopolygon.raster_field = field; rastertopolygon.simplify = simplify; //执行GP工具 IGeoProcessorResult results = (IGeoProcessorResult)gp.Execute(rastertopolygon, null); #endregion circularProgress1.IsRunning = false; #region 运行完成之后的信息提示窗口 balloonTipFocus.Enabled = true; DevComponents.DotNetBar.Balloon b = new DevComponents.DotNetBar.Balloon(); b.Style = eBallonStyle.Alert; //b.CaptionImage = balloonTipFocus.CaptionImage.Clone() as Image; b.CaptionText = "信息提示"; b.Text = "运行成功!"; b.AlertAnimation = eAlertAnimation.TopToBottom; b.AutoResize(); b.AutoClose = true; b.AutoCloseTimeOut = 4; b.Owner = this; b.Show(button4, false); #endregion }