# Convert line to polygon

**URL:** <https://community.thinkgeo.com/t/convert-line-to-polygon/577>\
**Category:** WinForms\
**Created:** [July 30, 2009, 9:14am UTC](https://community.thinkgeo.com/t/convert-line-to-polygon/577 "2009-07-30T09:14:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ted](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/t/db5fbb/32.png) [@Ted](https://community.thinkgeo.com/u/Ted)\
**Post date:** [July 30, 2009, 9:14am UTC](https://community.thinkgeo.com/t/convert-line-to-polygon/577/1 "2009-07-30T09:14:32Z")

</div>

I&nbsp;let&nbsp;my&nbsp;users&nbsp;to&nbsp;track&nbsp;a&nbsp;polygon&nbsp;line&nbsp;to&nbsp;measure&nbsp;a&nbsp;length.&nbsp;&nbsp;&nbsp;If&nbsp;they&nbsp;get&nbsp;close&nbsp;to&nbsp;their&nbsp;starting&nbsp;point,&nbsp;I&nbsp;assume&nbsp;they&nbsp;wanted&nbsp;to&nbsp;draw&nbsp;a&nbsp;polygon&nbsp;and&nbsp;know&nbsp;the&nbsp;area&nbsp;as&nbsp;well.&nbsp;&nbsp;&nbsp;Given&nbsp;a&nbsp;LineShape,&nbsp;how&nbsp;can&nbsp;I&nbsp;add&nbsp;the&nbsp;closing&nbsp;vertex&nbsp;and&nbsp;create&nbsp;a&nbsp;PolygonShape?

Thanks!

---

<div class="post-metadata">

**Author:** ![Ted](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/t/db5fbb/32.png) [@Ted](https://community.thinkgeo.com/u/Ted)\
**Post date:** [July 30, 2009, 9:46am UTC](https://community.thinkgeo.com/t/convert-line-to-polygon/577/2 "2009-07-30T09:46:45Z")

</div>

Never&nbsp;mind…&nbsp;I&nbsp;found&nbsp;it:&nbsp;  
&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PolygonShape&nbsp;polygon&nbsp;=&nbsp;new&nbsp;PolygonShape(new&nbsp;RingShape(line.Vertices));&nbsp;  
&nbsp;&nbsp;  
&nbsp;Where&nbsp;line&nbsp;is&nbsp;a&nbsp;LineShape.

---

<div class="post-metadata">

**Author:** ![ThinkGeo](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/thinkgeo/32/25029_2.png) [@ThinkGeo](https://community.thinkgeo.com/u/ThinkGeo)\
**Post date:** [July 30, 2009, 7:43pm UTC](https://community.thinkgeo.com/t/convert-line-to-polygon/577/3 "2009-07-30T19:43:19Z")

</div>

Ted,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks&nbsp;for&nbsp;your&nbsp;post&nbsp;and&nbsp;sharing!&nbsp;  
&nbsp;&nbsp;  
&nbsp;You&nbsp;are&nbsp;correct,&nbsp;while&nbsp;still&nbsp;I&nbsp;want&nbsp;to&nbsp;mention&nbsp;one&nbsp;thing&nbsp;is&nbsp;Ring&nbsp;Shape&nbsp;should&nbsp;be&nbsp;a&nbsp;closed&nbsp;area&nbsp;type&nbsp;shape,&nbsp;while&nbsp;line&nbsp;shape&nbsp;DONOT&nbsp;need&nbsp;to&nbsp;be&nbsp;closed,&nbsp;and&nbsp;it&nbsp;is&nbsp;line&nbsp;type&nbsp;shape.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Let&nbsp;me&nbsp;know&nbsp;if&nbsp;you&nbsp;have&nbsp;any&nbsp;more&nbsp;questions.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Yale&nbsp;

---

<div class="post-metadata">

**Author:** ![Ted](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/t/db5fbb/32.png) [@Ted](https://community.thinkgeo.com/u/Ted)\
**Post date:** [July 30, 2009, 7:51pm UTC](https://community.thinkgeo.com/t/convert-line-to-polygon/577/4 "2009-07-30T19:51:25Z")

</div>

Well,&nbsp;it&nbsp;was&nbsp;interesting.&nbsp;&nbsp;&nbsp;When&nbsp;I&nbsp;first&nbsp;tested&nbsp;that,&nbsp;I&nbsp;guess&nbsp;I&nbsp;got&nbsp;lucky,&nbsp;and&nbsp;my&nbsp;beginning&nbsp;and&nbsp;ending&nbsp;vertices&nbsp;were&nbsp;coincidental.&nbsp;&nbsp;&nbsp;And,&nbsp;when&nbsp;I&nbsp;added&nbsp;the&nbsp;resultant&nbsp;shape&nbsp;to&nbsp;the&nbsp;TrackOverlay.TrackShapeLayer,&nbsp;it&nbsp;drew&nbsp;as&nbsp;a&nbsp;polygon.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Later&nbsp;in&nbsp;the&nbsp;day,&nbsp;I&nbsp;could&nbsp;not&nbsp;get&nbsp;the&nbsp;resultant&nbsp;shapes&nbsp;to&nbsp;draw,&nbsp;however,&nbsp;the&nbsp;GetArea&nbsp;method&nbsp;returned&nbsp;a&nbsp;value&nbsp;that&nbsp;appears&nbsp;to&nbsp;be&nbsp;correct.&nbsp;  
&nbsp;&nbsp;  
&nbsp;The&nbsp;light&nbsp;finally&nbsp;came&nbsp;on,&nbsp;and&nbsp;I&nbsp;added&nbsp;a&nbsp;closing&nbsp;vertex&nbsp;when&nbsp;original&nbsp;vertices&nbsp;were&nbsp;NOT&nbsp;coincidental,&nbsp;and&nbsp;then&nbsp;the&nbsp;shape&nbsp;draws.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks&nbsp;for&nbsp;the&nbsp;confirmation.

---

<div class="post-metadata">

**Author:** ![ThinkGeo](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/thinkgeo/32/25029_2.png) [@ThinkGeo](https://community.thinkgeo.com/u/ThinkGeo)\
**Post date:** [July 30, 2009, 7:55pm UTC](https://community.thinkgeo.com/t/convert-line-to-polygon/577/5 "2009-07-30T19:55:51Z")

</div>

Ted,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks&nbsp;for&nbsp;your&nbsp;post&nbsp;and&nbsp;I&nbsp;am&nbsp;glad&nbsp;you&nbsp;fixed&nbsp;it!&nbsp;  
&nbsp;&nbsp;  
&nbsp;Let&nbsp;me&nbsp;know&nbsp;if&nbsp;you&nbsp;have&nbsp;any&nbsp;more&nbsp;questions!&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Yale&nbsp;
