Skip To Content

To GeoCoordinateString

Description

The toGeoCoordinateString operation is performed on a geometry service resource. The operation converts an array of x,y coordinates into well-known strings based on the conversion type and spatial reference supplied by the user. Optional parameters are available for some conversion types. Note that if an optional parameter is not applicable for a particular conversion type, but a value is supplied for that parameter, the value will be ignored.

Request parameters

ParameterDetails
sr

Specifies the well-known ID of the spatial reference or a spatial reference json object. For a list of valid WKID values, see Using spatial references.

coordinates

Specifies an array of x,y coordinates in JSON format to be converted.

Syntax

[[x1,y1],...[xN,yN]]

Example

[[10,10],[10,20], [30,30]]
conversionType

Specifies the conversion type of the input strings. Valid conversion types are as follows:

  • MGRS - Military Grid Reference System
  • USNG - United States National Grid
  • UTM - Universal Transverse Mercator
  • GeoRef - World Geographic Reference System
  • GARS - Global Area Reference System
  • DMS - Degree Minute Second
  • DDM - Degree Decimal Minute
  • DD - Decimal Degree
conversionMode

(Optional)

Specifies the conversion options for MGRS and UTM conversion types. Valid conversion modes for MGRS are as follows:

  • mgrsDefault - Default. Uses the spheroid from the given spatial reference.
  • mgrsNewStyle - Treats all spheroids as new, like WGS 1984. The 180 degree longitude falls into Zone 60.
  • mgrsOldStyle - Treats all spheroids as old, like Bessel 1841. The 180 degree longitude falls into Zone 60.
  • mgrsNewWith180InZone01 - Same as mgrsNewStyle except the 180 degree longitude falls into Zone 01.
  • mgrsOldWith180InZone01 - Same as mgrsOldStyle except the 180 degree longitude falls into Zone 01.

Valid conversion modes for UTM are as follows:

  • utmDefault - Default. No options.
  • utmNorthSouth - Uses north/south latitude indicators instead of zone numbers. Non-standard. Default is recommended.
numOfDigits

(Optional)

Sets the number of digits to output for each of the numerical portions in the string. The default value for numOfDigits varies depending on conversionType:

  • MGRS: 5
  • USNG: 8
  • UTM: NA
  • GeoRef: 5
  • GARS: NA
  • DMS: 2
  • DDM: 4
  • DD: 6

rounding

(Optional)

If true, numeric portions of the string are rounded to the nearest whole magnitude as specified by numOfDigits. Otherwise, numeric portions of the string are truncated. The rounding parameter applies only to conversion types MGRS, USNG, and GeoRef. The default value is true.

Values: true | false

addSpaces

(Optional)

If true, spaces are added between components of the string. The addSpaces parameter applies only to conversion types MGRS, USNG, and UTM. The default value for MGRS is false, while the default value for both USNG and UTM is true.

Values: true | false

f

The response format. The default format is html.

Values: html | json | pjson

Example usage

The following is a sample request URL for toGeoCoordinateString that demonstrates how to convert three sets of x,y coordinates to geographic strings in MGRS.

https://machine.domain.com/webadaptor/rest/services/Utilities/Geometry/GeometryServer/toGeoCoordinateString?sr=4326&coordinates=[[180,0],[-117,34],[0,52]]&conversionType=MGRS&conversionMode=mgrsNewWith180InZone01&numOfDigits=8&addSpaces=true&f=pjson

JSON Response syntax

The output is a JSON object containing an array of strings.

{"strings":[<string1>,...,<stringN>]}

JSON Response example

The output of the example given above is a JSON object containing an array of three strings. Notice that 180 degrees longitude is in Zone 01.


{
  "strings": [
    "01N AA 66021443 00000000",
    "11S NT 00000000 62155978",
    "31U BT 94071081 65288255"
  ]
}