Show / Hide Table of Contents

Method ToUsng

ToUsng(MapPoint, Int32, Boolean)

Returns a formatted coordinate string in United States National Grid (USNG) notation representing the given MapPoint's location.

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

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

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

A USNG notation string representing the position of the given MapPoint.

Remarks

The precision value controls the number of digits used to represent each numerical easting and northing value within the USNG string. For example:

precision
parameter value
addSpaces
parameter value
Example output Approximate precision
(to 1 significant figure)
0 false 13TFJ 100km
1 false 13TFJ25 10km
2 false 13TFJ2359 1km
3 false 13TFJ237595 100m
4 false 13TFJ23745951 10m
5 false 13TFJ2374359512 1m
0 true 13T FJ 100km
1 true 13T FJ 2 5 10km
2 true 13T FJ 23 59 1km
3 true 13T FJ 237 595 100m
4 true 13T FJ 2374 5951 10m
5 true 13T FJ 23743 59512 1m

If the point's SpatialReference is NAD 27, then a suffix is added to the end of the formatted string. For example:

precision
parameter value
addSpaces
parameter value
Example output Approximate precision
(to 1 significant figure)
4 false 13TFJ23795929 (NAD 27) 10m
2 true 13T FJ 23 59 (NAD 27) 1km

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
Relevant samples
Format coordinates: Format coordinates in a variety of common notations.
In This Article
Back to top Copyright © 2022 Esri.