Does anyone know where I could find a library of code for converting Lat/Lon position to Military Grid Reference System (MGRS)? I'm looking for a C# implementation if possible.
Asked
Active
Viewed 9,257 times
11
-
5You may want to consider asking these forms of questions on http://gis.stackexchange.com – Reed Copsey Jul 30 '10 at 19:02
4 Answers
5
We ended up using GeoTrans and create a DLL from the code and using PInvoke to call the functions. We pulled the following from the source incase anyone wanted to know (minimal solution):
- polarst
- tranmerc
- ups
- utm
- mgrs
The PInvoke Signature we used:
[DllImport("mgrs.dll")]
public static extern int Convert_Geodetic_To_MGRS(
double Latitude,
double Longitude,
int Precision, // 1 to 5, we used 4 (10 square meters)
StringBuilder MGRS);
which corresponds to this function in mgrs.h:
MGRSDLL_API long __stdcall Convert_Geodetic_To_MGRS(
double Latitude,
double Longitude,
long Precision,
char* MGRS);

SwDevMan81
- 48,814
- 22
- 151
- 184
-
-
@SwDevMan81 can you please share the DLL? And the way how can i add it to my windows phone project – Muhammad Umar Apr 26 '16 at 05:42
3
CoordinateSharp is available as a Nuget package and can do just that.
Coordinate c = new Coordinate(40.57682, -70.75678);
c.MGRS.ToString(); // Outputs 19T CE 51307 93264

Tronald
- 1,520
- 1
- 13
- 31
2
You can use GDAL's C# wrappers to convert from lat/lon to UTM. You then just need to format the values appropriately for MGRS, since it's just UTM with a different numerical format.

Reed Copsey
- 554,122
- 78
- 1,158
- 1,373
2
Found on js if it's help...
https://github.com/codice/usng.js
usage-
var converter = new usngs.Converter();
alert(converter.LLtoMGRS(33.754032, -98.451233, 9));

Zvi Redler
- 1,708
- 1
- 18
- 29