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.


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; 
| 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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