private void 河流面转点ToolStripMenuItem_Click(object sender, EventArgs e)
{
ESRI.ArcGIS.Geodatabase.IWorkspaceFactory wsf = new ESRI.ArcGIS.DataSourcesFile.ShapefileWorkspaceFactory();
IWorkspace ws = wsf.OpenFromFile(@"F:\1-水利项目\安徽水利\0826处理", ); IFeatureClass autoStation = (ws as IFeatureWorkspace).OpenFeatureClass("淮河干流面");
IFeatureClass f1 = (ws as IFeatureWorkspace).OpenFeatureClass("河道范围点"); int num = autoStation.FeatureCount(null);
int k = ;
string file = @"F:\1-水利项目\安徽水利\ANSL20120808\ANSL\OutPut\淮河干流\hedaopolygon.txt";
if (File.Exists(file))
{
File.Delete(file);
}
StreamWriter writer = new StreamWriter(file, true);
string strpt = "";
for (int i = ; i < num; i++)
{
IPolygon pg = autoStation.GetFeature(i).Shape as IPolygon; IPointCollection ptc = pg as IPointCollection;
for (int j = ; j < ptc.PointCount; j++)
{
IPoint pt = ptc.get_Point(j);
k++;
IFeature fea = f1.CreateFeature();
fea.Shape = pt;
fea.set_Value(fea.Fields.FindField("Id"), k);
fea.set_Value(fea.Fields.FindField("longi"), pt.X);
fea.set_Value(fea.Fields.FindField("latit"), pt.Y);
fea.Store(); strpt=strpt+pt.X+","+pt.Y+","+"0,";
}
strpt = strpt + ptc.get_Point().X + "," + ptc.get_Point().Y + "," + "0,";
}
writer.Write(strpt);
writer.Close();
}
IPolygon转换为IPoint,且点的坐标值写入txt中。