Is SRID 4326 Lon/Lat or Lat/Lon?

Is SRID 4326 Lon/Lat or Lat/Lon?



I built a wep app storing GPS coordinates, as SRID 4326. Coordinates are stored as Lon/Lat, and that was working fine on MySQL 5.6 and MySQL 5.7.



Since I upgraded to MySQL 8, I get the following error when trying to construct such a geometry:


SELECT ST_GeomFromText('POINT(-118 0)', 4326);



Latitude -118.000000 is out of range in function st_geomfromtext. It must be within [-90.000000, 90.000000].



I checked the MySQL documentation on SRS, which shows this entry for SRID 4326:


DEFINITION: ...
AXIS["Lat",NORTH],AXIS["Long",EAST]



Confirming that they assume it's Lat/Lon.



I've always seen SRID 4326 referenced as Lon/Lat before:



However, I just discovered the epsg.io site, that may be the canonical reference on the subject (?) that states that latitude comes first:



Axes: latitude, longitude.



So, which one should I trust? Is it Lat/Lon or Lon/Lat?





Comments are not for extended discussion; this conversation has been moved to chat.
– Ian Turton
Aug 25 at 9:09




1 Answer
1



In principle, it should always be lat/lon as that is what the current EPSG database defines it as. Unfortunately, over the years computer scientists have visited and made a decision to use lon/lat as that works for their high school maths mapping to X,Y and is easy.



So whenever you receive a file of coordinates in EPSG:4326 you need to check who sent them to you, if either of the columns exceeds 90 or plot them on a map and see if they are in the right place. If you are using someone else's code you should look inside the code and see what they are doing. Ideally you will see something like:


double ulLon, ulLat;
// Let's get upper-left corner coords
CRS.AxisOrder aorder = CRS.getAxisOrder(reqExtentInTileCrs.getCoordinateReferenceSystem());
switch (aorder)
case EAST_NORTH:
ulLon = reqExtentInTileCrs.getMinX();
ulLat = reqExtentInTileCrs.getMaxY();
break;
case NORTH_EAST:
if (LOGGER.isLoggable(Level.FINE)) LOGGER.log(Level.FINE, "Inverted tile coords!");
ulLon = reqExtentInTileCrs.getMinY();
ulLat = reqExtentInTileCrs.getMaxX();
break;
default:
LOGGER.log(Level.WARNING, "unexpected axis order " + aorder);
return ret;





Comments are not for extended discussion; this conversation has been moved to chat.
– Ian Turton
Aug 25 at 9:08






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

ャフサォクコ ケウ,コ,ワ メ,ロスョノ゙,クネ,フムカヤヲニ,エコ゚ツ ウイオン゙ケワサネォキモュキォウイノンコチ゚メヌナイゥフュ,カヒウネェ ネ,ホノケ,ムュキ ッボーミュハ,チ ツス ィ メウイマヤ,゙ウチ ヅ ロ,ォジヌェ ャヌット ェ,マャ,チナエヒネソキツテ トホヲヲミーァ

Node.js puppeteer - Use values from array in a loop to cycle through pages