# Projecting EllipseShape

**URL:** <https://community.thinkgeo.com/t/projecting-ellipseshape/2131>\
**Category:** WinForms\
**Created:** [November 14, 2012, 1:29pm UTC](https://community.thinkgeo.com/t/projecting-ellipseshape/2131 "2012-11-14T13:29:38Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![shaun](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/s/f07891/32.png) [@shaun](https://community.thinkgeo.com/u/shaun)\
**Post date:** [November 14, 2012, 1:29pm UTC](https://community.thinkgeo.com/t/projecting-ellipseshape/2131/1 "2012-11-14T13:29:38Z")

</div>

Hi&nbsp;All,

I&nbsp;am&nbsp;using&nbsp;version&nbsp;6.0&nbsp;and&nbsp;i&nbsp;have&nbsp;wgs84&nbsp;data&nbsp;that&nbsp;i'm&nbsp;projecting&nbsp;to&nbsp;spherical&nbsp;mercator.&nbsp;&nbsp;The&nbsp;data&nbsp;shows&nbsp;as&nbsp;expected&nbsp;on&nbsp;the&nbsp;map.&nbsp;&nbsp;The&nbsp;problem&nbsp;i'm&nbsp;having&nbsp;is&nbsp;that&nbsp;i'm&nbsp;trying&nbsp;to&nbsp;draw&nbsp;a&nbsp;range&nbsp;ring,&nbsp;using&nbsp;an&nbsp;inmemory&nbsp;feature&nbsp;layer&nbsp;that&nbsp;i&nbsp;add&nbsp;an&nbsp;ellipse&nbsp;(circle)&nbsp;to.&nbsp;&nbsp;The&nbsp;circle&nbsp;draws&nbsp;fine,&nbsp;but&nbsp;when&nbsp;i&nbsp;check&nbsp;the&nbsp;radius&nbsp;distance,&nbsp;it&nbsp;is&nbsp;wrong.&nbsp;&nbsp;How&nbsp;do&nbsp;i&nbsp;get&nbsp;the&nbsp;diameter&nbsp;of&nbsp;the&nbsp;circle&nbsp;to&nbsp;be&nbsp;correct?

&nbsp;

Thanks.

&nbsp;

Shaun

---

<div class="post-metadata">

**Author:** ![Ryan](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/r/a8b319/32.png) [@Ryan](https://community.thinkgeo.com/u/Ryan)\
**Post date:** [November 14, 2012, 4:39pm UTC](https://community.thinkgeo.com/t/projecting-ellipseshape/2131/2 "2012-11-14T16:39:46Z")

</div>

Hi&nbsp;Shaun,&nbsp;&nbsp;  
&nbsp;Thanks&nbsp;for&nbsp;your&nbsp;question!&nbsp;  
&nbsp;&nbsp;  
&nbsp;We&nbsp;are&nbsp;going&nbsp;to&nbsp;need&nbsp;additional&nbsp;information&nbsp;about&nbsp;the&nbsp;issue&nbsp;to&nbsp;be&nbsp;able&nbsp;to&nbsp;assist.&nbsp;&nbsp;  
&nbsp;First&nbsp;we&nbsp;need&nbsp;to&nbsp;know&nbsp;what&nbsp;MapUnit&nbsp;your&nbsp;map&nbsp;is&nbsp;using.&nbsp;  
&nbsp;Second&nbsp;what&nbsp;values&nbsp;are&nbsp;you&nbsp;using&nbsp;to&nbsp;provision&nbsp;your&nbsp;Ellipse?&nbsp;Are&nbsp;you&nbsp;using&nbsp;meters,&nbsp;DecimalDegrees?&nbsp;  
&nbsp;Third,&nbsp;what&nbsp;mechanism&nbsp;are&nbsp;you&nbsp;using&nbsp;to&nbsp;retrieve&nbsp;the&nbsp;radius&nbsp;of&nbsp;your&nbsp;Ellipse&nbsp;and&nbsp;what&nbsp;are&nbsp;the&nbsp;value&nbsp;do&nbsp;you&nbsp;expect&nbsp;to&nbsp;get&nbsp;and&nbsp;what&nbsp;value&nbsp;are&nbsp;you&nbsp;receiving.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Do&nbsp;you&nbsp;have&nbsp;any&nbsp;screenshots&nbsp;of&nbsp;the&nbsp;values&nbsp;you&nbsp;are&nbsp;recieving&nbsp;or&nbsp;perhaps&nbsp;a&nbsp;code&nbsp;sample&nbsp;that&nbsp;can&nbsp;show&nbsp;us&nbsp;how&nbsp;you&nbsp;have&nbsp;these&nbsp;elements&nbsp;setup?&nbsp;  
&nbsp;&nbsp;  
&nbsp;&nbsp;

---

<div class="post-metadata">

**Author:** ![shaun](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/s/f07891/32.png) [@shaun](https://community.thinkgeo.com/u/shaun)\
**Post date:** [November 15, 2012, 11:48am UTC](https://community.thinkgeo.com/t/projecting-ellipseshape/2131/3 "2012-11-15T11:48:10Z")

</div>

Thanks&nbsp;for&nbsp;the&nbsp;response&nbsp;Ryan,&nbsp;&nbsp;here&nbsp;is&nbsp;what&nbsp;i&nbsp;got:

1.&nbsp;&nbsp;Map&nbsp;Unit&nbsp;is&nbsp;Meters.

2.&nbsp;The&nbsp;data&nbsp;i'm&nbsp;displaying&nbsp;is&nbsp;wgs84&nbsp;and&nbsp;i&nbsp;project&nbsp;it&nbsp;from&nbsp;Epsg(4326)&nbsp;to&nbsp;Epsg(3785)

3.&nbsp;The&nbsp;ellipseshape&nbsp;is&nbsp;created&nbsp;as&nbsp;EllipseShape(point,&nbsp;Meter,&nbsp;Meter)

4.&nbsp;To&nbsp;measure&nbsp;the&nbsp;diameter&nbsp;of&nbsp;the&nbsp;circle&nbsp;i&nbsp;have&nbsp;a&nbsp;RulerOverlay&nbsp;that&nbsp;is&nbsp;a&nbsp;TrackInteractiveOverlay.&nbsp;&nbsp;It's&nbsp;projection&nbsp;is:

Internal&nbsp;(3785)&nbsp;External&nbsp;(4326).&nbsp;&nbsp;I&nbsp;project&nbsp;the&nbsp;WorldCoord&nbsp;X,&nbsp;Y&nbsp;to&nbsp;get&nbsp;the&nbsp;correct&nbsp;wgs84&nbsp;distance.

This&nbsp;ruler&nbsp;works&nbsp;perfect&nbsp;for&nbsp;the&nbsp;data&nbsp;i&nbsp;display,&nbsp;but&nbsp;when&nbsp;i&nbsp;draw&nbsp;an&nbsp;ellipse&nbsp;and&nbsp;measure&nbsp;it&nbsp;with&nbsp;the&nbsp;same&nbsp;ruler,&nbsp;the&nbsp;diameter&nbsp;is&nbsp;not&nbsp;what&nbsp;is&nbsp;expected.

I&nbsp;think&nbsp;what&nbsp;needs&nbsp;to&nbsp;happen&nbsp;is&nbsp;that&nbsp;i&nbsp;need&nbsp;to&nbsp;draw&nbsp;the&nbsp;ellipse&nbsp;in&nbsp;decimal&nbsp;degrees&nbsp;then&nbsp;project&nbsp;it&nbsp;to&nbsp;(3785),&nbsp;but&nbsp;i&nbsp;don't&nbsp;know&nbsp;how&nbsp;to&nbsp;project&nbsp;it&nbsp;correctly.

---

<div class="post-metadata">

**Author:** ![shaun](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/s/f07891/32.png) [@shaun](https://community.thinkgeo.com/u/shaun)\
**Post date:** [November 16, 2012, 10:38am UTC](https://community.thinkgeo.com/t/projecting-ellipseshape/2131/4 "2012-11-16T10:38:52Z")

</div>

Does&nbsp;anyone&nbsp;know&nbsp;how&nbsp;to&nbsp;project&nbsp;an&nbsp;inmemory&nbsp;feature&nbsp;layer&nbsp;from&nbsp;wgs84&nbsp;to&nbsp;Mercator?

---

<div class="post-metadata">

**Author:** ![Ryan](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/r/a8b319/32.png) [@Ryan](https://community.thinkgeo.com/u/Ryan)\
**Post date:** [November 16, 2012, 5:03pm UTC](https://community.thinkgeo.com/t/projecting-ellipseshape/2131/5 "2012-11-16T17:03:35Z")

</div>

Hi&nbsp;Shaun,

You&nbsp;can&nbsp;can&nbsp;convert&nbsp;all&nbsp;of&nbsp;the&nbsp;features&nbsp;contained&nbsp;in&nbsp;your&nbsp;InMemoryFeatureLayer&nbsp;by&nbsp;using&nbsp;the&nbsp;following:

`Proj4Projection proj = new Proj4Projection();        proj.InternalProjectionParametersString = Proj4Projection.GetDecimalDegreesParametersString();        proj.ExternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(3785);                InMemoryFeatureLayer inMemoryFeatureLayer = new InMemoryFeatureLayer();        inMemoryFeatureLayer.FeatureSource.Projection = proj;`

---

<div class="post-metadata">

**Author:** ![shaun](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/s/f07891/32.png) [@shaun](https://community.thinkgeo.com/u/shaun)\
**Post date:** [November 16, 2012, 5:27pm UTC](https://community.thinkgeo.com/t/projecting-ellipseshape/2131/6 "2012-11-16T17:27:54Z")

</div>

Ryan,

When&nbsp;would&nbsp;this&nbsp;be&nbsp;done,&nbsp;after&nbsp;the&nbsp;features&nbsp;are&nbsp;added,&nbsp;or&nbsp;when&nbsp;the&nbsp;inmemoryfeature&nbsp;layer&nbsp;is&nbsp;created?

---

<div class="post-metadata">

**Author:** ![shaun](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/s/f07891/32.png) [@shaun](https://community.thinkgeo.com/u/shaun)\
**Post date:** [November 16, 2012, 6:39pm UTC](https://community.thinkgeo.com/t/projecting-ellipseshape/2131/7 "2012-11-16T18:39:46Z")

</div>

Well,&nbsp;I&nbsp;think&nbsp;i&nbsp;finally&nbsp;figured&nbsp;it&nbsp;out.&nbsp;&nbsp;I&nbsp;copied&nbsp;code&nbsp;from&nbsp;one&nbsp;ot&nbsp;the&nbsp;examples&nbsp;that&nbsp;creates&nbsp;an&nbsp;ellipseshape&nbsp;and&nbsp;adds&nbsp;the&nbsp;ellipse&nbsp;to&nbsp;the&nbsp;layer&nbsp;like&nbsp;so:

lyr.open();

lyr.EditTools.BeginTransaction()

EllipseShape&nbsp;rng&nbsp;=&nbsp;new&nbsp;EllipseShape(...);

lyr.EditTools.Add(new&nbsp;Feature(rng));

lyr.EditTools.committransaction();

lyr.close();

The&nbsp;above&nbsp;code&nbsp;doesn't&nbsp;project&nbsp;the&nbsp;ellipse&nbsp;correctly,&nbsp;even&nbsp;after&nbsp;setting&nbsp;the&nbsp;projection&nbsp;like&nbsp;Ryan&nbsp;posted&nbsp;above.

The&nbsp;mistake&nbsp;was&nbsp;not&nbsp;adding&nbsp;the&nbsp;ellipseShape&nbsp;to&nbsp;the&nbsp;layer&nbsp;as&nbsp;an&nbsp;InternalFeature.&nbsp;&nbsp;Once&nbsp;i&nbsp;did&nbsp;that,&nbsp;the&nbsp;projection&nbsp;works&nbsp;fine.

---

<div class="post-metadata">

**Author:** ![Edgar](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/e/b487fb/32.png) [@Edgar](https://community.thinkgeo.com/u/Edgar)\
**Post date:** [November 18, 2012, 11:44pm UTC](https://community.thinkgeo.com/t/projecting-ellipseshape/2131/8 "2012-11-18T23:44:42Z")

</div>

Hi&nbsp;Shaun,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Glad&nbsp;to&nbsp;hear&nbsp;that&nbsp;you&nbsp;find&nbsp;a&nbsp;right&nbsp;way&nbsp;to&nbsp;solve&nbsp;the&nbsp;problem,&nbsp;there&nbsp;is&nbsp;something&nbsp;different&nbsp;between,&nbsp;InternalFeatures.Add()&nbsp;and&nbsp;EditTools.Add(),&nbsp;the&nbsp;feature&nbsp;added&nbsp;by&nbsp;method&nbsp;InternalFeatures.Add()&nbsp;must&nbsp;be&nbsp;the&nbsp;non-projected&nbsp;one,&nbsp;and&nbsp;the&nbsp;feature&nbsp;added&nbsp;by&nbsp;method&nbsp;EditTools.Add()&nbsp;must&nbsp;be&nbsp;the&nbsp;projected&nbsp;one,&nbsp;so&nbsp;I&nbsp;think&nbsp;you&nbsp;are&nbsp;adding&nbsp;the&nbsp;non-projected&nbsp;one&nbsp;in&nbsp;your&nbsp;previous&nbsp;code.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Regards,&nbsp;  
&nbsp;Edgar
