# How calculate polygon dimensions

4420
8
08-18-2014 11:09 PM
New Contributor III

Dear All

There is a way to calculate polygon dimensions (Side) , if i ma working on ArcObject (Java or .NET) any suggestions  ...

especially with complex polygon

Thanks

Tags (3)
8 Replies
MVP Legendary Contributor

I think the term is "perimeter" that you are looking for.  Did you do a search using    arcobjects perimeter  first?

New Contributor III

Dear Mr.Dan

I am not looking for perimeter  i am looking for dimensions for each side ...

see what i meant >>>

by
MVP Frequent Contributor

you can see code in this link : IPolygon4.ExteriorRingBag Property (ArcObjects .NET 10 SDK)

in this code when you loop on points you can get distance from point(i) to point(i+1) ...

by
MVP Frequent Contributor

... if your polygons are composed from only lines ...

Occasional Contributor III

Below my suggestion, never implemented this scenario personally before just a possible solution

• Cast your polygon to ISegmentCollection
• Iterate through each segment
• Use ReturnTurnDirection ArcObjects 10 .NET SDK Help‌ on your segments
• If No Turn returned ArcObjects 10 .NET SDK Help then sum your segment length
• Whenever there is a turn break your summation and restart
• At the end you loop you would have got your dimensions.
New Contributor III

Thanks Riyas for your post ,  i saw what you put and really interesting idea , but how i can do that in coding level , if

you have any idea plz help me ...thanks

Occasional Contributor III

Hi Najd,

Try below code.

Note: Even if there is a suttle change in direction between segments (i.e. not exactly 180 degree), it'll be treated as change and gets counted as different section.

Do post back if this worked.

```                        ISegmentCollection segments = (ISegmentCollection)lta.Shape;
List<double> dimensions = new List<double>();
if (segments != null)
{
double length = 0;
for (int idx = 0; idx < segments.SegmentCount; idx++)
{
ISegment currentSegemnt = segments.get_Segment(idx);

if (idx + 1 < segments.SegmentCount)
{
ISegment otherSegment = segments.get_Segment(idx + 1);

if (currentSegemnt.ReturnTurnDirection(otherSegment) != 1)
{
length = 0;
}
}
else
{