This document is archived and information here might be outdated.  Recommended version.


IConversionMGRS.CreateMGRS Method (ArcObjects .NET 10.5 SDK)
ArcObjects Library Reference (Geometry)  

IConversionMGRS.CreateMGRS Method

Returns the MGRS/USNG description of a point.

[Visual Basic .NET]
Public Function CreateMGRS ( _
    ByVal numDigits As Integer, _
    ByVal round As Boolean, _
    ByVal mode As esriMGRSModeEnum _
) As String
[C#]
public string CreateMGRS (
    int numDigits,
    bool round,
    esriMGRSModeEnum mode
);
[C++]
HRESULT CreateMGRS(
  Long numDigits,
  VARIANT_BOOL round,
  esriMGRSModeEnum mode,
  BSTR* mgrs
);
[C++]

Parameters numDigits numDigits is a parameter of type Long round round is a parameter of type VARIANT_BOOL mode
mode is a parameter of type esriMGRSModeEnum mgrs [out, retval] mgrs is a parameter of type BSTR

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Description

This method creates a single string description in MGRS/USNG for any Point on the Earth's surface.  A string variable is needed to store this alphanumeric string. MGRS stands for military grid reference system while USNG is the United States National Grid. CreateMGRS takes three inputs.

The first is the integer number of digits you wish the string to carry and controls the precision.

0: To approximately 100 kilometers depending on where on earth the point is.

5: To a square meter (This is the standard for MGRS/USNG).

8: To a square millimeter. This is the best precision possible and using a larger number will not result in greater precision.

The second input parameter is a boolean that represents rounding.

True: The values of the UTM coordinates will be rounded.

False: The values of the UTM coordinates will be truncated.

The second is the esriMGRSModeEnum and determines how to handle the geographic coordinate system of the spatial reference. Certain older geographic coordinate systems will cause one of the letters of the string to be shifted. This process makes it easier to identify coordinates that are based on a non-WGS84 datum.

esriMGRSModeEnum:

esriMGRSMode_Automatic: the geographic coordinate system is handled for you

esriMGRSMode_NewStyle: the geographic coordinate system is treated as if it is WGS84

esriMGRSMode_NewWith180InZone01: the geographic coordinate system is treated as if it is WGS84 and a point at 180E will be forced into UTM zone 1.

esriMGRSMode_OldStyle: the geographic coordinate system is treated as if it is an older non-WGS84 datum, particularly one that is based on the Clarke 1866 or Bessel spheroids.

esriMGRSMode_OldWith180InZone01: the geographic coordinate system is treated as if it is an older non-WGS84 datum, particularly one that is based on the Clarke 1866 or Bessel spheroids and a point at 180E will be forced into UTM zone 1.

esriMGRSMode_USNG: USNG does not differentiate between older and newer geographic coordinate systems.

[C#]

IPoint pnt=new PointClass();

pnt.SpatialReference =// previously created Spatial Reference;

IConversionMGRS convertpnt=pnt as IConversionMGRS;

string MGRSstring=convertpnt.CreateMGRS(5,true,0);

 

See Also

IConversionMGRS Interface