Show / Hide Table of Contents

Method ToMgrs

ToMgrs(MapPoint, MgrsConversionMode, Int32, Boolean)

Returns a formatted coordinate string in Military Grid Reference System (MGRS) notation representing the given MapPoint's location.

Declaration
public static string ToMgrs(MapPoint point, MgrsConversionMode mgrsConversionMode, int precision, bool addSpaces)
Parameters
Type Name Description
MapPoint point

The location to be represented in MGRS notation. It must have a SpatialReference set.

MgrsConversionMode mgrsConversionMode

The MgrsConversionMode to use for the returned MGRS notation string.

System.Int32 precision

The precision with which to represent the coordinate. Value is expected to be between 0 to 8 (inclusive), and will be clamped if necessary.

System.Boolean addSpaces

If false, the generated string contains no spaces. If true, a space separates the grid zone designator, the 100km square identifier, and the numerical easting/northing values.

Returns
Type Description
System.String

An MGRS notation string representing the position of the given MapPoint.

Remarks

For an explanation of the different modes for interpreting an MGRS notation string, please see MgrsConversionMode. Note that the choice between zone 01 and 60 has an impact only when generating the MGRS notation string for a point with a longitude of exactly 180 degrees. The precision parameter controls the number of digits used to represent each numerical easting and northing value within the returned MGRS string. For example:

precision
parameter value
addSpaces
parameter value
Example output Approximate precision
(to 1 significant figure)
0 false 30UVG 100km
1 false 30UVG89 10km
2 false 30UVG8999 1km
3 false 30UVG898998 100m
4 false 30UVG89889988 10m
5 false 30UVG8988499881 1m
0 true 30U VG 100km
1 true 30U VG 8 9 10km
2 true 30U VG 89 99 1km
3 true 30U VG 898 998 100m
4 true 30U VG 8988 9988 10m
5 true 30U VG 89884 99881 1m

Exceptions
Type Condition
System.ArgumentNullException

point is null.

System.ArgumentException

point does not have a spatial reference.

Applies to

Platforms and versions
TargetVersions
.NET Standard 2.0100.3 - 200.7
.NET100.13 - 200.7
.NET Windows100.13 - 200.7
.NET Android200.0 - 200.7
.NET iOS200.0 - 200.7
.NET Framework100.1 - 200.7
Xamarin.Android100.1 - 100.15
Xamarin.iOS100.1 - 100.15
UWP100.1 - 200.7
In This Article
Back to top Copyright © 2022 Esri.