I am making a buffer in an ArcGIS Pro Add-in. How do I set the Units?

389
1
01-24-2020 10:07 AM
SteveScott
New Contributor III

I am making a buffer in an ArcGIS Pro Add-in. How do I set the units? GeometryEngine.Instance.Buffer() takes a geometry and a distance. How do I get the map's units so I can choose the metric or US value I give the buffer method?

0 Kudos
1 Reply
MichaelPemberton1
New Contributor

Hi Steve,

You may want to look at the ArcGISDynamicMapServiceLayer 

Example

private void theArcGISDynamicMapServiceLayer_Initialized(object sender, EventArgs e) {
   // Get the ArcGISDynamicMapServiceLayer.   
   ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer theArcGISDynamicMapServiceLayer = null;   
   theArcGISDynamicMapServiceLayer = (ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer)sender;     
   // Get and display the ArcGISDynamicMapServiceLayer.Units information.  
   string theUnits = theArcGISDynamicMapServiceLayer.Units;  
   TextBlock_Units.Text = theUnits;      
   // Get and display the ArcGISDynamicMapServiceLayer.SpatialReference information.  
   ESRI.ArcGIS.Client.Geometry.SpatialReference theSpatialReference = theArcGISDynamicMapServiceLayer.SpatialReference;   
   if (theSpatialReference != null)   {     
      int theWKID = theSpatialReference.WKID;     
      string theWKT = theSpatialReference.WKT;     
      if (theWKID != 0)     {       
         TextBlock_SpatialReference.Text = "WKID: " + theWKID.ToString();     
      }       
      else    
      {       
         TextBlock_SpatialReference.Text = "WKT: " + theWKT;     
      }   
   } 
}