ArcMap中有没有批量删除Polyline中折角的工具?


QQ截图20171011110427.jpg

如上图,等高线上有很多折角,有什么方法可以批量去除掉红框里的节点,使得polyline平滑连接
已邀请:

richard86

赞同来自: 江宝骅 zsf

已通ArcEngine解决
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ESRI.ArcGIS.DataSourcesFile;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.Carto;

namespace quzejiao
{
public partial class Form1 : Form
{
private string shpFile;
private string shpFilePath;
private string shpFileName;
private IFeatureClass pFC;
public Form1()
{
InitializeComponent();
shpFile = string.Empty;
shpFilePath = string.Empty;
shpFileName = string.Empty;
pFC = null;
}

private void btnShp_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "shp文件|*.shp";

openFileDialog.RestoreDirectory = true;
openFileDialog.FilterIndex = 1;
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
shpFile = openFileDialog.FileName;
textBox1.Text = shpFile;
shpFilePath = System.IO.Path.GetDirectoryName(shpFile);
shpFileName = System.IO.Path.GetFileNameWithoutExtension(shpFile);
textBox1.Text = shpFile;
IWorkspaceFactory pWSF = new ShapefileWorkspaceFactoryClass();
IWorkspace pWS = pWSF.OpenFromFile(shpFilePath, 0);
IFeatureWorkspace pFWS = pWS as IFeatureWorkspace;
pFC = pFWS.OpenFeatureClass(shpFileName);
}
}

private void btnOK_Click(object sender, EventArgs e)
{
if (pFC != null)
{

IFeatureCursor pFCursor = pFC.Update(null, false);
IFeature pF = pFCursor.NextFeature();
int k = 0;
label1.Text = "正在输出……";
Application.DoEvents();
while (pF != null)
{
k++;
IPolyline polyline = pF.ShapeCopy as IPolyline;
IPointCollection pPointCollection = polyline as IPointCollection;
IPointCollection pPointCollection0 = new PolylineClass();
pPointCollection0.AddPoint(pPointCollection.get_Point(0));
int length = pPointCollection.PointCount;
ILine pLine0 = null;
ILine pLine1 = null;
for (int i = 0; i < length - 2; i++)
{
pLine0 = new LineClass();
pLine1 = new LineClass();

pLine0.ToPoint = pPointCollection.get_Point(i);
pLine0.FromPoint = pPointCollection.get_Point(i + 1);
pLine1.FromPoint = pPointCollection.get_Point(i + 1);
pLine1.ToPoint = pPointCollection.get_Point(i + 2);

Double dAngle = (pLine1.Angle - pLine0.Angle) * (180 / Math.PI);
if (Math.Abs(dAngle) > 90)//保留角度大于90的角
{
pPointCollection0.AddPoint(pPointCollection.get_Point(i + 1));
}
}
IPolyline pNewLine = pPointCollection0 as IPolyline;
pF.Shape = pNewLine as IGeometry;
pFCursor.UpdateFeature(pF);
if (k == 100)
{
pFCursor.Flush();
k = 0;
}

pF = pFCursor.NextFeature();
}
pFCursor.Flush();
System.Runtime.InteropServices.Marshal.ReleaseComObject(pFCursor);
label1.Text = "";
MessageBox.Show("Game Over");
}
}
}
}

要回复问题请先登录注册