基于C#的AE二次开发之Shapefile矢量要素的筛选
在利用arcgis软件做数据处理的时候,我们经常会遇到矢量要素的筛选问题,如何快速准确的从shapfile文件的大量要素中挑选出自己需要的要素数据、如何根据给定的范围快速准确的筛选出相关区域的矢量数据等。这里采用基于C#的AE二次开发方式来完成该筛选工作。
1、程序界面
程序通过两种筛选方式来挑选要素,第一种通过指定某个字段的要素值列表来挑选矢量要素,第二种通过指定矢量范围来挑选要素。第一种方式的程序思路可分为:读取矢量文件、获取矢量字段并显示在listbox控件上、筛选字段值、另存结果矢量文件几步;第二种方式的程序思路为:读取矢量文件、判断空间相交关系、筛选要素、另存结果矢量文件几步。核心代码如下:
private void button4_Click(object sender, EventArgs e)//执行
{
//IAoInitialize m_AoInitialize = new AoInitializeClass();
//m_AoInitialize.Initialize(esriLicenseProductCode.esriLicenseProductCodeAdvanced);
//string THname = Clipboard.GetText();
if (this.textBox1.Text.Trim().Length == 0)
{
MessageBox.Show("请选择筛选数据路径!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
this.textBox1.Focus();
}
else if (this.textBox2.Text.Trim().Length == 0)
{
MessageBox.Show("请选择指定列表路径!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
this.textBox2.Focus();
}
else if (this.textBox3.Text.Trim().Length == 0)
{
MessageBox.Show("请选择结果保存路径!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
this.textBox3.Focus();
}
else
{
if (!Directory.Exists(this.textBox3.Text.Trim()))
{
Directory.CreateDirectory(this.textBox3.Text.Trim());
}
string strin_features = this.textBox1.Text.Trim();
string strsplit_features = this.textBox2.Text.Trim();
string strout_features = this.textBox3.Text.Trim();
ArrayList TxtList = new ArrayList();
string strLine;
StreamReader sr = new StreamReader(this.textBox2.Text.Trim(), Encoding.Default);
while ((strLine = sr.ReadLine())