Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have seen this code in Arcpy which is used to create a Polygon from a string of Points(X , Y).Can you please let me know how I can us something like this which can generate polygon from an array of X,y values in C# and Arcobjects?

I already take alook at Arcobjects 10 .net framework sample code sample of Building a Polygon Using Points . but it was too confusing for me.

I really appreciate your time if you can point me to a tutorial or a sample which contains a process of polygon creation same as what was in arcpy code.

share|improve this question
add comment

1 Answer 1

Here's one way to do it. There's probably a better way.

void IPointCollection makePC(List<IPoint> pList)
{

IGeometryBridge2 pGeoBrg = new GeometryEnvironment() as IGeometryBridge2;
IPointCollection4 pPointColl = new PolylineClass();
int numPoints = pList.Count; 
WKSPoint[] aWKSPointBuffer = new WKSPoint[numPoints];
for(int i =0; i < pList.Count; i++)
{
WKSPoint A = new WKSPoint();
A.X = pList[i].X;
A.Y = pList[i].Y;
aWKSPointBuffer[i] = A;
}
pGeoBrg.SetWKSPoints(pPointColl, ref aWKSPointBuffer);

return pPointColl; 
}
share|improve this answer
    
Hi Patrick and thanks for your comment, but my problem is I do not know how to create a shapefile! before adding the points. –  user1106951 Aug 2 '12 at 15:17
    
@user1106951 Then ask a different question –  patrick Aug 2 '12 at 15:40
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.