I'm updating my script which reads a spreadsheet of values including coordinates but the spreadsheet is not formatted as a table par se. Instead of projected X and Y coordinates, I'd like to move to the user inputting a single MGRS value for each coordinate/position required.
This requires conversion back into X and Y values for the actual processing (i.e. arcpy.point(x,y)).
Unfortunately, the arcpy.ConvertCoordinateNotation requies a input table and gives an output featureclass and I'm dealing with discreet values. In other words, I just want to give an MGRS (string) and get a UTM X (long) & Y (long) from arcpy....the tool isn't designed to work at that fundamental level which seems odd.
So, working through that, it seems as if, given a single MGRS value I need to
....and that's for a single conversion.
So my question is: "Is that the best way"?! It seems very convoluted.
If you're willing to use ArcObjects check out IConversionNotation or IConversionMGRS.
I'm keeping it within python as I also use this script as both a toolbox tool and web geoprocessing service.
The method I outlined above does work and is fast enough for what I'm doing...it just seems really convoluted compared to say
utmCoords = arcpy.convertCoordinateNotation(input coordinates = [x,y],input format = 'MGRS', output format = 'UTM') returning a tuple utmCoords[0] = <x coord> utmCoords[1] = <y coordinate> or string etc?
I had a similar need to convert single points between MGRS and lat long
I found this package does the trick: mgrs · PyPI. It converts single points between MGRS and UTM or Lat Long.
I had to pip install mgrs, since the conda package manager only wants to support 'optimized' packages. When I installed the conda package from https://anaconda.org/conda-forge/mgrs, using conda on the command line, the package wanted to make a lot of changes to the default core python environment shipped with ArcGIS Pro 2.5.
After installing the pip package to a cloned environment, I needed to reactivate the default environment and then switch back to the cloned environment before the package was recognized.