[C#] Distance Units of a Layer

675
1
Jump to solution
04-07-2013 03:33 PM
ConorBarber1
New Contributor II
Hello,

I am developing an ArcGIS desktop addin. I am attempting to get the distance units (ft, mm, km, etc.) from a layer in my .mxd and display it on a windows form. How can I do this? I can access the distance units of a map by using IMap.DistanceUnits, but I have had trouble accessing the distance units of an individual layer.
0 Kudos
1 Solution

Accepted Solutions
ConorBarber1
New Contributor II
Someone answered this for me on another forum. The solution they provided is to use IProjectedCoordinateSystem.CoordinateUnit. I was working with an ILayer, which uses ILayer.AreaOfInterest.SpatialReference. IProjectedCoordinateSystem inherits from SpatialReference, and can be accessed through casting:

 ESRI.ArcGIS.Geometry.IProjectedCoordinateSystem lyrCoordSystem = (IProjectedCoordinateSystem)pLayer.AreaOfInterest.SpatialReference;  lblSpatialReference.Text = lyrCoordSystem.CoordinateUnit.Name;  

View solution in original post

0 Kudos
1 Reply
ConorBarber1
New Contributor II
Someone answered this for me on another forum. The solution they provided is to use IProjectedCoordinateSystem.CoordinateUnit. I was working with an ILayer, which uses ILayer.AreaOfInterest.SpatialReference. IProjectedCoordinateSystem inherits from SpatialReference, and can be accessed through casting:

 ESRI.ArcGIS.Geometry.IProjectedCoordinateSystem lyrCoordSystem = (IProjectedCoordinateSystem)pLayer.AreaOfInterest.SpatialReference;  lblSpatialReference.Text = lyrCoordSystem.CoordinateUnit.Name;  
0 Kudos