4

I am able to draw the circle but I want a circle of radius 3 kms

I have checked all the previous posts.

I want to know what is the units of radius in the below code.

var radius, circle, ring, pts, angle;
var currentPoint = new esri.geometry.Point(longitude, latitude, this.parent.esriMap.spatialReference);
currentPoint = esri.geometry.geographicToWebMercator(currentPoint);
circle = new esri.geometry.Polygon(this.parent.esriMap.spatialReference);
ring = []; // point that make up the circle 
pts = 40; // number of points on the circle 
angle = 360 / pts; // used to compute points on the circle 
for (var i = 0; i <= 360; i = i + 10) {
 var radian = i * (Math.PI / 180.0);
 var x1= radius * Math.cos(radian);
 var y1= radius * Math.sin(radian);
 var circlePoint = new esri.geometry.Point(x1, y1, this.parent.esriMap.spatialReference);
 circlePoint = esri.geometry.geographicToWebMercator(circlePoint);
 points[i] = new esri.geometry.Point(
 parseFloat(circlePoint.x) + parseFloat(currentPoint.x), parseFloat(circlePoint.y) + parseFloat(currentPoint.y),
 this.parent.esriMap.spatialReference);
 ring.push(points[i]);
}
circle.addRing(ring);
//rest code to add the layers to map
PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Aug 20, 2014 at 6:52
0

2 Answers 2

4

Creating a 3km radius circle is quite easy in ArcGIS Desktop:

  1. Create a point featureclass marking the center of your area of interest.
  2. Use the Buffer (Analysis) tool to create the 3km radius buffer around the point featureclass.

enter image description here

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
answered Aug 20, 2014 at 7:00
2

When solving it programmatically I would start with this Snippet from ESRI:

Create Graphic Buffers around Selected Features Snippet:

///<summary>Draws graphic buffers around the selected features in the map using distance units specified.</summary>
///
///<param name="activeView">An IActiveView interface.</param>
///<param name="distance">A System.Double that is the distance in map units around the select features to draw a graphic buffer. Example: 10</param>
/// 
///<remarks></remarks>
public void CreateGraphicBuffersAroundSelectedFeatures(ESRI.ArcGIS.Carto.IActiveView activeView, System.Double distance)
{
 //parameter check
 if (activeView == null || distance < 0)
 {
 return;
 }
 ESRI.ArcGIS.Carto.IMap map = activeView.FocusMap;
 // Clear any previous buffers from the screen
 ESRI.ArcGIS.Carto.IGraphicsContainer graphicsContainer = (ESRI.ArcGIS.Carto.IGraphicsContainer)map; // Explicit Cast
 graphicsContainer.DeleteAllElements();
 // Verify there is a feature(s) selected
 if (map.SelectionCount == 0)
 {
 return;
 }
 // Reset to the first selected feature
 ESRI.ArcGIS.Geodatabase.IEnumFeature enumFeature = (ESRI.ArcGIS.Geodatabase.IEnumFeature)map.FeatureSelection; // Explicit Cast
 enumFeature.Reset();
 ESRI.ArcGIS.Geodatabase.IFeature feature = enumFeature.Next();
 // Buffer all the selected features by the buffer distance and create a new polygon element from each result
 ESRI.ArcGIS.Geometry.ITopologicalOperator topologicalOperator;
 ESRI.ArcGIS.Carto.IElement element;
 while (!(feature == null))
 {
 topologicalOperator = (ESRI.ArcGIS.Geometry.ITopologicalOperator)feature.Shape; // Explicit Cast
 element = new ESRI.ArcGIS.Carto.PolygonElementClass();
 element.Geometry = topologicalOperator.Buffer(distance);
 graphicsContainer.AddElement(element, 0);
 feature = enumFeature.Next();
 }
 activeView.PartialRefresh(ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGraphics, null, null);
}

available at: http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#//0049000000n3000000

this takes a feature point geometry as input but you could create your own geometry with the coordinates of the buffer you want to draw. The distance is in map units but following site might help you get the relation to the geographic distance:

ArcGis Desktop Help: About setting distance units

http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=About_setting_distance_units

answered Aug 20, 2014 at 7:31
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.