Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I want to create a circle with IPoint P and radius r in ArcEngine and then I need to cast it to an IGeometry. Does anyone know how to do this?

ESRI ArcEngine 10 VS2010 C#

share|improve this question
add comment

4 Answers 4

up vote 4 down vote accepted

found it

ISegmentCollection p = new PolygonClass();
p.SetCircle(mousepoint, 20);
IGeometry circleGeo = p as IGeometry;
share|improve this answer
    
Kudos for this. You are correct, and I don't think a lot of people know about the SegmentCollection and the various Set methods that get used along with it. This answer adds greatly useful information to the gis.stackexchange pool. –  celticflute Jan 17 '11 at 22:26
    
@celticflute sorry to report that it doesn't work properly after some testing –  patrick Jan 17 '11 at 22:34
    
I'm curious - what kind of test did it fail? –  Kirk Kuykendall Jan 18 '11 at 2:47
    
@Kirk Kuykendall it created the circle in the wrong place –  patrick Jan 18 '11 at 14:47
1  
@Kirk, iterationx: I just tested this and seems to work perfectly for me... –  Petr Krebs Jan 19 '11 at 17:39
show 2 more comments

EllipticArcClass ellipticalArc = new EllipticArcClass();

IEnvelope env = new EnvelopeClass();

IPoint lowerLeft = new PointClass();

lowerLeft.X = centerPoint.X - width;

lowerLeft.Y = centerPoint.Y - height;

IPoint upperRight = new PointClass();

upperRight.X = centerPoint.X + width;

upperRight.Y = centerPoint.Y + height;

env.LowerLeft = lowerLeft;

env.UpperRight = upperRight;

ellipticalArc.ConstructEnvelope(env);

IGraphicTrackerSymbol graphicTrackerSymbol = this.graphicTracker.CreateSymbol(simpleFillSymbol, null);

int shapeId = this.graphicTracker.Add(ellipticalArc, graphicTrackerSymbol);

share|improve this answer
add comment

Another method is to cast your point to ITopologicalOperator and use the Buffer method to buffer the point by the radius.

share|improve this answer
    
I think this method works for Projected coordinate systems, but will give strange results if you are working with a Geographic coordinate system. –  Devdatta Tengshe Jan 31 '11 at 4:07
add comment

I prefer the ISegmentCollection solution myself, but you can also recast your IPoint or IGeometry as ITopologicalOperator and call the Buffer method.

share|improve this answer
    
-1 for basically taking two of the answers, restating the same, and adding no value. –  Petr Krebs Jan 29 '11 at 10:32
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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