How can I automatically count the number of corners that has a polygon using VBA and ArcObjects?

  • 3
    Wouldn't the count of corners be the same as the count of points (less one, since the start and end points are the same)? Obviously a "corner" in this case may not be very apparent to the eye; I guess it depends upon what you mean by corner. – Michael Todd Jun 2 '11 at 4:57
  • Although I managed to count the number of points of each polygon the problem is that even a polygon may be approximately rectangular actually has more than four points because of the digitization process i.e. sometimes an approximate straight line consists of more than 2 points. How can I ignore the intermmediate points? Thanks. – Demetris Jun 9 '11 at 11:03

Strictly speaking, the number of corners, is one less than the number of vertices in the polygon.

You should cast the geometry (IPolygon) to IPointCollection. The IPointCollection.Pointcount property gives you the number of vertices.

Just subtract one to get the number of corners.

  • Good idea; but the number of vertices e.g. saying a rectangle polygon has the same number of corners (i.e. points) with the number of vertices and not one less. Isn't it? – Demetris Jun 2 '11 at 11:16
  • 1
    A square polygon can have 5 vertices - one for the start, 3 for each point on the square and one for the end. So the start and end vertex equal each other. But that's not always the case. You'll need to compare start and end vertex, if they are the same then minus one. Also you'll need to code for donut and multipart polygons if they exist in the dataset. – Rob Clark Jun 2 '11 at 11:20
  • 1
    I would think also looking for an angle less than 180 would also be needed to account for psuedo nodes. – Brad Nesom Jun 2 '11 at 14:38
  • 1
    How many corners does a circular polygon have? – Kirk Kuykendall Jun 2 '11 at 14:51
  • 2
    @Hairy makes excellent points. The comments by @Kirk and @Dan remind us, though, that there's more than geometry involved here. We need to bear in mind the difference between a geometric object and its representation in the GIS. Taking "polygon," "square," etc. in their geometric senses leads to Hairy's clarification. But Dan points out a geometric square might have a representation with more than four nodes (plus one wrap-around node); and Kirk, with his probing question, reminds us that in many GIS contexts even a "circle" is of the same type as a "polygon." – whuber Jun 16 '11 at 19:55

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.