Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UTM coordinates outputting with zone letters instead of typical hemispheric value (south/north) #1151

Open
rudokemper opened this issue Mar 12, 2024 · 10 comments
Labels

Comments

@rudokemper
Copy link
Member

Working with a community in the Pacific, I'm noticing that their UTM coordinates are outputting in this format: UTM 57L xxxxxx xxxxxx. At first I thought the "L" might refer to a latitude band, but after some quick research it's clear that doesn't seem to make sense. I thought to try to change the "L" to "S" which is my expectation for the hemisphere value, the Observations data is then correctly interpreted and located in the right place.

I'm now in the Northern hemisphere, so I tried to capture an observation here. The UTM coordinates output by Mapeo are UTM 18S xxxxxx xxxxxx. When I changed the "S" to "N", the coordinates were correct.

I don't know what "L" / "S" could refer to, and I tried to poke around a bit in the repo to see if I could spot anything, but wasn't able to. Typically, the default value for UTM hemisphere is always S/N, and there is quite a bit of logic relating to S/N in the code, so I'm left with the conclusion that this is an outputting bug.

@rudokemper rudokemper added the bug label Mar 12, 2024
@achou11
Copy link
Member

achou11 commented Mar 12, 2024

my guess is that the "L" and "S" you're seeing refer to the zone letter, which seems to be part of the format spec and essentially represent the latitude bands that you initially thought they were (https://maptools.com/tutorials/grid_zone_details)

library we use for getting utm coordinates:

https://github.com/TimothyGu/utm/blob/master/index.es.js#L29

my guess is that we do some processing of the original output of the conversion that eventually leads to an inaccurate representation of the coordinate (probably somewhere in this file:
https://github.com/digidem/mapeo-mobile/blob/develop/src/frontend/screens/ManualGpsScreen/UtmForm.tsx), but my domain knowledge is a little too limited to know immediately. either that or just a bug due to some pretty fragile react code that I wrote in that screen 😅

@rudokemper
Copy link
Member Author

rudokemper commented Mar 12, 2024

I think you are right! The zone letters of "L" and "S" check out with the two geographies that I've tested (the island in the Pacific and my current location). And the comments in this function note the two different conventions of hemisphere or latitude bands, and offers a workaround for cases where the latitude band value is actually N or S. So, it might have been intentional to show zone letter instead of hemisphere, and therefore not a bug.

But: I've personally never seen a UTM coordinate convention where the latitude bands are given instead of the hemisphere, neither in places that I've worked nor in GIS in general. I think outputting zone letter instead of hemisphere is probably not helpful or desired for most users.

@rudokemper rudokemper removed the bug label Mar 12, 2024
@rudokemper rudokemper changed the title UTM coordinates outputting with hemisphere "L"/"S" instead of expected S/N (south/north) UTM coordinates outputting with zone letters instead of typical hemispheric value (south/north) Mar 12, 2024
@achou11
Copy link
Member

achou11 commented Mar 12, 2024

yeah based on this part of the comments, seems like preferring the latitude band is intentional

// to use the latitude band if we can, since it is better for catching
// errors in coordinate entry.

@rudokemper
Copy link
Member Author

I think it makes sense for processing / catching errors, but not for what gets displayed to the end user on the screen or anywhere else. (I first encountered this via a WhatsApp share of an Observation, actually.)

If it's helpful to have a benchmark for common standards, QGIS also uses hemisphere to follow the zone number.

@achou11
Copy link
Member

achou11 commented Mar 12, 2024

I think it makes sense for processing / catching errors, but not for what gets displayed to the end user on the screen or anywhere else

that's a good distinction and definitely seems more actionable.

are you suggesting that it makes sense to use the latitude bands when manually entering the coordinates (entry or editing) but then when it's displayed in a read-only context, use the hemispheric letter?

@rudokemper
Copy link
Member Author

rudokemper commented Mar 12, 2024

Not quite. I'm suggesting that it might make sense for Mapeo to use latitude bands for internal processing of coordinate data or for catching errors (in whatever ways that it does, probably for working with the above UTM library - I haven't looked into it. so I'm taking that comment at face value). But if users are inserting or editing coordinates manually, they are much more likely to be inputting coords with a hemispheric value than with a latitude band. Although I suspect this has not come up before, because it seems to me that the use case of manually inserting or editing coordinates would be pretty rare.

Of course, the safest thing would be to allow the user to specify if they are using latitude bands or hemispheric letters. Easiest solution for that could be to just have two options for UTM coordinates in the coordinate selection screen. If you don't want to go that route, then you have no choice but to choose one over the other, and I'm suggesting to definitely go with hemisphere as that is the more common standard.

@rudokemper
Copy link
Member Author

Wikipedia actually has a good note on this! https://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system

Latitude bands are not a part of UTM,[7] but rather a part of the military grid reference system (MGRS).[8] They are however sometimes included in UTM notation. Including latitude bands in UTM notation can lead to ambiguous coordinates—as the letter "S" either refers to the southern hemisphere or a latitude band in the northern hemisphere—and should therefore be avoided.

@achou11
Copy link
Member

achou11 commented Mar 12, 2024

Not quite. I'm suggesting that it might make sense for Mapeo to use latitude bands for internal processing of coordinate data or for catching errors (in whatever ways that it does - I haven't looked into it. so I'm taking that comment at face value). But if users are inserting or editing coordinates manually, they are much more likely to be inputting coords with a hemispheric value than with a latitude band. Although I suspect this has not come up before, because it seems to me that the use case of manually inserting or editing coordinates would be pretty rare.

Of course, the safest thing to do would be to allow the user to specify if they are using latitude bands or hemispheric letters. The easiest way of doing that would be to just have two options for UTM coordinates in the coordinate selection screen. If you don't want to go that route, then you have no choice but to choose one over the other, and I'm suggesting to definitely go with hemisphere as that is the more common standard.

got it! thanks for clarifying - will have to consult the rest of the team about this kind of change and if it would meaningfully affect anyone, but what you've laid out makes a lot of sense

@ximenabb ximenabb added the bug label Mar 12, 2024
@gmaclennan
Copy link
Member

Just to jump in, since I wrote the parsing code and the original comment. What I meant by:

// to use the latitude band if we can, since it is better for catching
// errors in coordinate entry.

Is that we use the Y coordinate to determine what convention the user is using (hemisphere or zone letters) when trying to parse user input.

I am most used to seeing "N" for "Northern" and "S" for "Southern" with UTM coordinates, however the Garmin Etrex H (and I'm not sure if this is standard across all Garmin GPS) shows the UTM zone letter.

I hadn't actually noticed the use of a zone letter when displaying UTM. I think it makes sense for users if they are also using / seeing a GPS to see the UTM coordinates using the same format (e.g. zone letters), and it might be worth teaching that, although in Peru the general usage of UTM seems to be N/S rather than zone letters.

In summary, I don't know the right answer. For users who also use a GPS, it would be a confusing change to see the UTM format change to show something different to a GPS. We could add an additional format option, but that could be confusing for users (it really hard to explain the difference!).

@rudokemper
Copy link
Member Author

Yeah, I agree that it makes sense to show the same information as what users might see a handheld GPS @gmaclennan.

I have a vague recollection that on the Garmin GPSMAP 64, which I used in Suriname a decade ago, it was using hemispheric N/S instead of zone letter. I used to have to train what UTM coordinates are, and I remembering needing to explain what the equator was and why the UTM zone for Suriname (21N) shown on the GPS was in the northern hemisphere, hence 'N'.

But I poked around a bit online and it does seem the eTrex at least uses latitude bands and so does the GPSMAP 62.

I think handheld GPS units might be in the minority of using latitude bands; most other software (and indeed national land information systems) tend to use hemispheric N/S.

Definitely hard to think of a right answer here, short of introducing another format option. Maybe an imperfect solution can just be describing the reasoning for using zone letters in the Mapeo docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants