Skip to main content
deleted 348 characters in body
Source Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

This question Converting MGRS to Lat/Lon or UTM helped. I adapted the answer by Sasa Ivetic and although the solution is somewhat obscure, I hope it may help someone. If any of you think it wrong or imprecise for geeky cartographic reasons please let me know.

In order to convert coordinates from USNG/ MGRS to lon/lat, when there are far too many coordinates and you need to have it outomated:

1/ Get the [GeographicLib][1]GeographicLib package and use the GeoConvert utility.

2/ The general idea is to repeatedly call this utility from whatever tool you use (R, Python...), and supply user input and capture output.

3/ Specifically, and as an example, in Python 3.7, using the subprocess module, here are a couple of lines which can be looped:

from subprocess import Popen, PIPE
p = Popen('C:\\pkg-vc12-x64\\GeographicLib-1.49\\bin\\GeoConvert.exe', stdin=PIPE, stdout=PIPE)
p.communicate(b'48QYD307682')[0]

I also notice that the title of my question was misleading as I didn't mention that I need to automatically convert lots of coordinates, so I am going to fix it now. So my bad here.

Thank you all! [1]: https://geographiclib.sourceforge.io/

This question Converting MGRS to Lat/Lon or UTM helped. I adapted the answer by Sasa Ivetic and although the solution is somewhat obscure, I hope it may help someone. If any of you think it wrong or imprecise for geeky cartographic reasons please let me know.

In order to convert coordinates from USNG/ MGRS to lon/lat, when there are far too many coordinates and you need to have it outomated:

1/ Get the [GeographicLib][1] package and use the GeoConvert utility.

2/ The general idea is to repeatedly call this utility from whatever tool you use (R, Python...), and supply user input and capture output.

3/ Specifically, and as an example, in Python 3.7, using the subprocess module, here are a couple of lines which can be looped:

from subprocess import Popen, PIPE
p = Popen('C:\\pkg-vc12-x64\\GeographicLib-1.49\\bin\\GeoConvert.exe', stdin=PIPE, stdout=PIPE)
p.communicate(b'48QYD307682')[0]

I also notice that the title of my question was misleading as I didn't mention that I need to automatically convert lots of coordinates, so I am going to fix it now. So my bad here.

Thank you all! [1]: https://geographiclib.sourceforge.io/

Converting MGRS to Lat/Lon or UTM helped. I adapted the answer by Sasa Ivetic and the solution is somewhat obscure.

In order to convert coordinates from USNG/ MGRS to lon/lat, when there are far too many coordinates and you need to have it outomated:

1/ Get the GeographicLib package and use the GeoConvert utility.

2/ The general idea is to repeatedly call this utility from whatever tool you use (R, Python...), and supply user input and capture output.

3/ Specifically, and as an example, in Python 3.7, using the subprocess module, here are a couple of lines which can be looped:

from subprocess import Popen, PIPE
p = Popen('C:\\pkg-vc12-x64\\GeographicLib-1.49\\bin\\GeoConvert.exe', stdin=PIPE, stdout=PIPE)
p.communicate(b'48QYD307682')[0]
Source Link

This question Converting MGRS to Lat/Lon or UTM helped. I adapted the answer by Sasa Ivetic and although the solution is somewhat obscure, I hope it may help someone. If any of you think it wrong or imprecise for geeky cartographic reasons please let me know.

In order to convert coordinates from USNG/ MGRS to lon/lat, when there are far too many coordinates and you need to have it outomated:

1/ Get the [GeographicLib][1] package and use the GeoConvert utility.

2/ The general idea is to repeatedly call this utility from whatever tool you use (R, Python...), and supply user input and capture output.

3/ Specifically, and as an example, in Python 3.7, using the subprocess module, here are a couple of lines which can be looped:

from subprocess import Popen, PIPE
p = Popen('C:\\pkg-vc12-x64\\GeographicLib-1.49\\bin\\GeoConvert.exe', stdin=PIPE, stdout=PIPE)
p.communicate(b'48QYD307682')[0]

I also notice that the title of my question was misleading as I didn't mention that I need to automatically convert lots of coordinates, so I am going to fix it now. So my bad here.

Thank you all! [1]: https://geographiclib.sourceforge.io/