Select to view content in your preferred language

Using MGRS coords from xls to create Point/Line/Poly Features

894
5
01-03-2024 11:37 PM
jaschofskiAGS
Emerging Contributor

Hello community,

I'm very new to python and try to rebuild/optimize workflows I've done in Modelbuilder.

My current problem set:

I have an xls containing multiple rows and collum's. one of them is a Coordinate Field, containing MGRS coordinates. 

Each row represents either a Point, Line or Polygon (dedicated by a Field called "Type").
For Lines and Polygons, the Coordinate field contains multiple MGRS coordinates, separate by a semicolon.

 Up to now I always separated the sheet manually by point Line and Area and convert the multiple coordinates into multiple rows using power queries in xls and a model in ArcPro to create the features.

What I'm looking for is a pythonic way to create the point features (from here I get it on my own to lines and polygons) from the xls, using the MGRS as CoordString directly and not using the ConvertCoordinate Tool. I thought about the combination of Search- and InsertCursors plus the FromCoordString function because I don't have xy formatted coordinates, but I don't find a starting point.

If anyone has experience in using MGRS(or simmilar cordString) to create features, I would be very thankful for any suggestions!

ArcPro Version is 2.6.1

0 Kudos
5 Replies
DavidPike
MVP Frequent Contributor

Is there a reason not to use the coordinate conversion tool in python?  You could probably do it using a dictionary to get the cartesian coords (for that UTM zone) of the GZD and 100km grid square in the MGRS string, then add on the X and Y.  If that dictionary doesn't exist somewhere on the internet, then seems like a fair amount of effort for no reason I can understand.

0 Kudos
jaschofskiAGS
Emerging Contributor

most likely the reason is, that the xlc sheet contains also cells with up to a few 100 chars and Pagebreaks.
From my experience with the Convert Coordinates Tool it will not translate these cells properly from time to time (at least in ModelBuilder) that's why I was looking for a solution to take The MGRS coord directly to create the point features instead of converting them first, but it seems as if there is no appropriate workaround.

0 Kudos
jaschofskiAGS
Emerging Contributor

Or let me formulize my question another way around. Is there a way to convert MGRS coordinates which are stored in a single xls Cell, separated by a semicolon and use this coord list to create a point feature class?

0 Kudos
JohannesBierer
Frequent Contributor

Maybe you can use python to split and expand the coordinates in two cells, python example:

https://stackoverflow.com/questions/37600711/pandas-split-column-into-multiple-columns-by-comma

0 Kudos
jaschofskiAGS
Emerging Contributor

That helped me with the Multi-coord cells, but still not with cresting points from MGRS coord. 

I just wonder if there is nobody worked with MGRS to create points without of using the coordConverter tool

0 Kudos