Lon Lat Lon Lat
macwright.com
macwright.com
As the linked post says, Lon/Lat is generally easier to deal with b/c it matches to X/Y (and the North/Up way we look at maps). But you still have annoyances. For instance Lon goes 0-360 but Lat goes -90 to 90. This is also mathematically inconvenient
Add on top of that the X-Y coordinate on images generally have the X flipped and starting at the top left corner. So changing to Lon/Lat doesn't fix everything.
What I personally lean towards now is converting everything on read-in to a South/East coordinate system so it matches the flipped X-Y of images (like GeoTIFFs) and just always working in that system. Image manipulation, drawing to screen, output etc. - those systems/libraries I can't really modify myself. Everything else I can manipulate in whatever coordinate system I want. So it makes sense to choose the most convenient. Plus only dealing with positive coordinates is a big plus.
That all said, I'm a total noob and I have no "geospatial" background (just writing some software to deal with rain data right now) So this isn't pro advice. I'd just be curious what others think
I have a dirty prototype I need to rewrite soon so I was considering a coordinate system change. It'd make debugging much easier if the values drawn and the values of the coordinates had the same "directions"
I was a bit apprehensive to just yolo my own internal coordinate system bc it's a design decision you end up having to live with
Surely this is several typos? Longitude, which marks east-west, must span 360 degrees (-180 to 180, perhaps? although 0 to 360 is just as reasonable). Latitude, marking north-south, spans only 180 degrees, and therefore is presumably -90 to 90 (so that 0 is the equator).
Altitude
Vertical
If I ever need to confirm which is which, I use the the mnemonic above. I usually imagine latitude corresponding to rings on the earth moving up and down along the surface. This image is triggered by thinking about "altitude" in the context of latitude for me.
The latitude defines which of these "rings" the point is on.
https://cdn.britannica.com/07/64907-050-7ACA69C8/Facts-paral...
What I propose is to go "all the way" and make an internal positive/unsigned South/East coordinate system that naturally matches the display coordinate system (the inverted X-Y). It's sufficiently different that you'll never get confused and flip things at API boundaries. It's also sufficiently weird that you won't expose it to others :)
If things are looking weird or wrong on your display then you need to go back to your internal values to inspect what's wrong. When the internal value covary with th display values then this makes life significantly easier
Not to mention things have a tendency to blow up when you start testing in the southern hemisphere haha
That said.. I don't personally use any magic plotting packages. I just generate my own graphics with svg. It's quite easy and everything is debuggable
Going super close to the poles should be a challenge for both mercator and equirectangular projections, but at least Mercator won't distort shapes at the same time (and neither is globally accurate for area).
yeah, you're completely right!
Just be glad we don't universally use Minecraft XYZ coordinates.
More radical would be to go from degrees to the 0 UINT_MAX range and have your unsigned values automatically wrap around. You'd have the range wrap around naturally. But it's nice to have degrees for debugging and it's not tied to a type so you can have arbitrary precision. I also think you'd still have corner cases to deal with (but I'll have to think about this some more)
There is also the convenience of having your coordinates change in the same way as your display coordinates. So if something displays off of where it should then you can easily diagnose the problem. Everything is always in units of degrees relative to the top left corner (with maybe a scale factor) - whether you're looking at the whole globe or just a region. With a signed coordinate you'd be relative to the image center which is not how your display works. You need to track offsets and image widths/heights. Debugging gets nastier and you have off by one problems and whatnot. That's just been my experience so far
For people that actually work in geospatial, there is no advantage to the lat/lon order and the lon/lat order has been the standard for decades already. Arguing about the order of polar coordinates is fighting a battle that was literally settled decades ago.
https://en.wikipedia.org/wiki/ISO_6709#Order,_sign,_and_unit...
EPSG:4326 also uses lat/long: https://epsg.org/crs_4326/WGS-84.html
It's also worth pointing out that a lot of this is conflating display order in UIs (which usually is lat/lon, often in DMS) with storage order and API conventions (which are usually lon/lat).
Many early standards conflicted (e.g. coordinate order) or were under-specified (e.g. polygon winding). The Open Geospatial Consortium (OGC), whence many of these ISO standards came, sensibly made the decision many years ago that all future standards should treat these in a consistent and fully-specified way. Because of the pervasiveness and vast quantity of data stored as ISO 19125, adopting the ISO 19125 conventions were the least costly way of resolving these conflicts.
I've been working with GIS data from every type of industry for a long time, and the only place I ever see lat/lon order is in user interfaces. At the data and software level it is always lon/lat for compatibility and interoperability.
There is little to be gained by re-litigating the lon/lat coordinate order, since no value is gained by changing it (the choice is arbitrary), virtually all modern software systems use the same conventions at this point, and in many cases these conventions are codified in law across many countries.
Isn't the reality that a bunch of software engineers wrote their software to use lon/lat because x, y is the intuitive ordering in the context of a cylindrical projection way of thinking, and ISO 19125 codified that common software practice without anyone really thinking about it or the conflicts it created?
That's hardly definitive, particularly when it contradicted ISO's own earlier standard (which codified the long-standing common communication practice of lat/lon). ISO standards themselves are weak without logical and practical commonplace usage backing them up, because the standards are paywalled.
Your experience, and the table in the OP article, shows that lon/lat has more usage in the software world, but that's not sufficient. There's enough confusion, and enough major players defecting from that recent "standard" of 19125, that the issue should be looked at again, re-litigated, and re-standardized. Everyone outside the narrow field of GIS software engineers and data wranglers expects lat/long. The issue has never been litigated at all outside of that insular world.
It seems like standardizing on the common practice (outside of the digital technical realm) of lat/lon is the right way to go:
The software world has the advantage that if there was consensus to change to lat/lon universally, they could patch it once, convert any data files once, and be done. The software world has much less inertia.
In contrast, the non-software world can't be readily converted to lon/lat. It's much more difficult to change people's everyday usage. Look at the mess caused by Americans using MM/DD/YYYY, or English-inspired use of Imperial over metric. It's difficult to convince people to change even when there are significant problems with the historical choice, and objective reasons for why they should change.
You are also grossly underestimating the scale of the lon/lat installed based. The lat/lon diehards are the inconsequential and insular part of the market by comparison.
There is no practical way to "patch" the countless exabytes of lon/lat currently sitting in cold storage. These are the largest data sets that exist, and it would be exceedingly unrealistic to expect the world to reformat this data, which they've been happily using up to this point, because a few people don't want to remember that the order is lon/lat. You might as well decree that everyone use XML to store their data while you're at it.
I literally don't care, because it doesn't actually matter. No amount of wishful thinking will cause a return to the imagined golden age of lat/lon.
Outside of the programming bubble we're not in a world where you ever need to think twice about the order. I don't go to Wikipedia and think "hmm I wonder which order they wrote their coordinates". I don't need to check the publication date of a map or book. I don't see that ever changing
And as I explained the benefits are kind of half-assed. If you want a more intuitive internal system than I think you can do better. You should full-ass it and re-zero it to whatever makes sense in your situation (or even change the units, or remap to go from degrees to the 0 UINT_MAX range and have your unsigned values automatically wrap around) - but keep the API in standard notation.
But maybe don't expose your projection in your API?
None of them are more correct, they’re just more convenient.
:-/
A lot of weird bugs happen at the edges/meridians. In a South/East system the edges are at the poles and in the middle of the Pacific Ocean. So you already eliminate weird southern hemisphere blow ups. Using wraparound would solve the Pacific problem I guess
Maybe unsigned long.. for some extra precision..
EDIT: unfortunately since I'm doing everything in Clojure unsigned math is kinda clunky :(
> Using wraparound would solve the Pacific problem I guess
I worked with such a coordinate system years ago, and there's definitely some advantages (fixed resolution, speed on some processors, memory usage) and some disadvantages ( not all software is wraparound aware and needs ported, debugging outside of decimal degrees is harder for me but I know some mathematicians who are more used to radians than anything else - perhaps you get used to it).
The debugging aspect may be a bit annoying I'll admit. Before printing you'd need to constantly convert your u_ints to degrees to make sense of them.
The main problems I'm seeing so far is that lon spans 360 and wraps around cleanly, but lat spans 180.. and when you go past the pole you don't actually wrap anywhere (you don't wanna jump to the other pole :)). What actually happens is that you end up on a different longitude. I'm not sure how to work around that. But then maybe you don't need to b/c that scenario shouldn't come up - while crossing the pacific will. At the moment I'm primarily shooting to select rectangular regions and then extract data (like elevation or precipitation) in those regions. Such a region could cross a meridian/equator - but it wouldn't make sense for it to go past the pole
On the JVM unsigned code is going to be a lot clunkier to write, but I'm hoping in the end it'll save me a ton of time debugging edge cases
1) Double the lat resolution and use two different scaling factors for converting each axis to degrees(less fun to debug, but hey, free 2x resolution or repurpose the LSB for something else)
2) Allow intermediate results on latitudes to temporarily enter the no-mans land between 90-180(and southern equivalent), then manually wrap back.
> On the JVM unsigned code is going to be a lot clunkier to write
Wikipedia has a comparison: https://en.m.wikipedia.org/wiki/Binary_angular_measurement
Having x-y=5 and y-x=-5 can be quite handy, but there's also some concerns about integer overflow in C/C++.
Some systems do this internally, it has advantages beyond the wraparound. They still export standard ISO compliant data format though since that is what everyone knows.
https://en.m.wikipedia.org/wiki/ISO_6709
By government systems do you mean US government systems?
Because the storage and interoperability of data is specified to use lon/lat, it strongly influences things that may not be specified by standard. Human user interfaces can do whatever they want, but software systems expect everything in lon/lat order.
There does still seem to be controversy on this point in tooling though? Popular tools like proj and pyproj now confusingly return different ordering for a different CRS, and a diff between UI conventions and code etc is really unfortunate and likely to cause bugs, so it doesn’t seem completely settled. e.g.
https://github.com/pyproj4/pyproj/issues/225 https://github.com/OSGeo/PROJ/commit/6a7e24dce79f93b73f4919f...
The vast majority of geospatial data is not intrinsically cartographic in nature and the primary use case is not making maps even if maps are sometimes used as a presentation layer. Consequently, cartographic conventions are correctly treated as legacy interfaces that require conversion into a modern standard; it wouldn't make sense for a modern software system to speak legacy standards natively.
Most modern geospatial data systems use an internal spatial reference system derived from WGS84 (not even straight EPSG:4326) that is optimized for efficient data processing. Remember, the vast majority of this data is primarily consumed by machines and virtually all of the data is required to be interoperable with machines. There is a very thin long tail of people using myriad legacy cartographic formats but they don't influence how geospatial data is handled because it is such a negligible percentage of the computing done on geospatial data these days.
Cartographically, in terms of standards, that seems to be the case. I don't think because libraries have been written which are backwards, that there should be some popularity contest - that's too small a bubble, just makes programmers sound like entitled asshats...
Even a govt. standard should not be the measuring stick - govts change policy with the wind, or different govts. The lon/lat programmers with the pitchforks are the upstart rebels here...
Lat/Lon
Sure Lat/Lon is the common presentation format for this particular coordinate system.
Right now in Sweden the time is 10:41 (it would be great if it was a couple of hours later, then I could say it's 14:41 to demonstrate the 24 hour time format). Yet, in software, I would represent that as time in UTC. Only when presenting to the user would I convert that to the users time zone.
My last name contain the letter "ö". In software, I would use an unicode string internally, then when writing out I would encoded that to utf-8. (20 years ago, I would have used an old character encoding called ISO/IEC 8859-1 or something like that, but you get my point).
For some damn reason I till don't understand, the decimal separator in Sweden is the comma and not the period. Still I would represent numbers internally as an integer or maybe float, and then when printing to to the user would I convert that to "123,4" (123.4) or something like that.
In Sweden, WGS84 is not the only common coordinate system. There are many others: SWEREF and SWEREF TM for example. Yes internally, depending on usecase, I would probably use a representation of WGS84 as reference, then convert that to present to the user...
This is how I think about coordinates.
Even if you are reading exotic data in some parochial format you internally probably wanna use one consistent format. If you have some massive data sets and don't wanna convert on read-in then there are way around that (you can setup a memoization system to convert and cache on as-needed basis). This format should be intuitive and convenient. I proposed a South/East format.. but you're free to choose whatever you want here. But the point is that Lon/Lat is likely never a good choice at this junction. It still has issues and you generally can do better.
At the interface the default we've arrived to as a society Lat/Lon WGS84 :) The merits here are irrelevant. If you want to support other i/o formats then you may. That really depends on your usecases - but they shouldn't map to whatever format you've decided on internally. And even if they did, you probably shouldn't be using Lon/Lat internally anyway
I'm curious to know the history of why (some?) Euro countries went with the common and the Anglo world went with the period. Some details:
> In France, the full stop was already in use in printing to make Roman numerals more readable, so the comma was chosen.[13] Many other countries, such as Italy, also chose to use the comma to mark the decimal units position.[13] It has been made standard by the ISO for international blueprints.[14] However, English-speaking countries took the comma to separate sequences of three digits. In some countries, a raised dot or dash (upper comma) may be used for grouping or decimal separator; this is particularly common in handwriting.
* https://en.wikipedia.org/wiki/Decimal_separator
ISO seems to say use a comma:
* https://en.wikipedia.org/wiki/ISO/IEC_80000#Part_2:_Mathemat...
I don't understand what distinction you're drawing here? UTF-8 is Unicode. In what way would you be modifying it at the presentation layer? (Unless you're dealing with true UI code, and are saying "I would map the characters to font glyphs according to the UTF-8 standard".)
I know UTF-8 isn't the only way of encoding Unicode codepoints, for what it's worth. I'm just struggling to see how you would be using just 'Unicode', as opposed to a particular encoding, at the storage layer. It's still just bits and bytes.
The conflict is about interfaces, specifically interfaces using unlabeled number pairs, between software and humans, or software and other software. It's unfortunate that anyone would implement software with lat/long inputs/outputs, and think that they have the privilege of defining that order however suits them; what they obviously should do, and should have done, is take a moment to think, "How have people communicated earth coordinates in the past? Are there any standards that might be applicable?" and used that order. Of course, if tradition and standards were bad for some objective reason, that might justify it. But not just because some programmer wants to export their way of dealing with coordinates in x, y coordinate order from a cylindrical projection. That's not sufficient reason to upend tradition and introduce confusion and ambiguity in cases of |longitude| <= 90°.
> Meters per second (m/s) is the SI unit for velocity and the unit recommended by the World Meteorological Organization for reporting wind speeds
> Since 2010 the International Civil Aviation Organization (ICAO) also recommends meters per second for reporting wind speed when approaching runways
For example, aviation deals heavily in flight levels (multiples of 100 ft). If flight levels are a first-class concept in your program, then you're already using non-SI units below the presentation layer. At this point you've established that some altitudes in your program are expressed in feet, and it might be a better idea to use feet for altitudes everywhere rather than introducing a lot of unit conversions. Or it might not be.
Kind of interesting, as well, to consider this when talking about lat/lon. Do those attempt to be SI?
Time for SI is still seconds.
Which isn't base-10, yet is SI. So depends on if you accept adopted SI, or want to jump on the base-10 SI clock/time bandwagon.
And lat/lon is based on angles, not distance, with lon coming from time (delta time between solar noon in two locations).
But the SI unit(less) for angles is radians.
So... no, but it depends on how you interpret multiple SI inconsistencies.
I recall that astronomical units are also not SI.
Mentioning computers is just a cheap shot, I admit. Still, is valid.
Cooking is an odd one. The old units that were largely defined in thirds are quite useful. Weight is, of course, more reliable for baking, but you can go very far at home quantities with cups and spoons.
To be fair, I'm a large believer that the units are arbitrary and whatever you learned will be good. Such that if you learned SI, it had advantages off the bat. But I am in less agreement that they have an intrinsic advantage.
So an airplane traveling due north at 120 knots would cover 2 degrees of latitude per hour.
Most of the US Customary and British Imperial units actually have similar logical definitions or derivations, but they aren't regularly taught anymore.
So, knots persist because lat lon persists. Home cooks persist with imperial in some places because nobody cares to reprint all recipes and measuring devices. Astrological units because at that scale... Nothing scales. And computers, because binary won. (Curious to consider if ternary had been the winner...)
I confess I am actually personally moved by some of the intuitive arguments for older measurements. Usually very physical based and very in tune with numbers actually used in an industry. It is odd to think of a sixteenth inch wrench, but it is just the natural result of dividing by two, four times, after all. (That is, you have a measuring rod, put a midpoint on there. Four times. Now, do the same for millimeters?). (granted, in the age of computers, any measurement is much easier to do at the machining level.)
>Usually very physical based
Land records in the US are all feet, acres, furlongs, arpents, sections, and townships.
That's not changing.
And they all divide easily from townships of 36-square miles to 10-acre quarter-quarter-quarter-sections to 66x660ft-acres.
66 ft is a gunter's (surveyors) chain = 100 links
10 chains = 660ft = 1 furlong = 1/8 mile
It's a brilliantly thought out system, but most people promoting SI won't take the time to see the benefits.
Personally, I find it much easier to make blunders with SI, because a decimal shift one place over isn't always an obvious mistake.
Usually Dunning-Kruger is present.
Oversimplified... but:
Most raw/original geo-referenced imagery in the US are projected in a SPCS (state plane coordinate system) in survey-feet, which aren't defined in x,y but n,e (Northing, Easting) or sometimes e,n. This order isn't as universal as x,y, for various reasons. (UTM in meters is also common for larger areas.)
SPCSs aren't all the same type of projections, so Lambert conic (parallel defined) vs Transverse Mercator (meridian defined) (the two most common) means the "first" measurement traversed isn't always the same. (On a sphere, if I tell you to go 100 miles north, then 100 miles east, you get to a different point than 100 miles east, then 100 miles north.)
Being grid systems, this shouldn't matter, but surveyors who used to do manual transformations would get in the habit of the order they regularly used.
So "flipped" is a matter of perspective.
It's one of those things that's a tell for someones educational background and localisms. Surveyor/Geographer/Geodesist vs Scientist/Mathematician/Software Developer.
Did a progammer-first person develop a particular file format, or did a cartography/geography-first person? Or some combination of a compromise?
>I have no "geospatial" background
Checks out.
If you're a learn-by-doing person, I recommend looking up the transformations for a few common CRS/datums/projections and going through the equations manually, either with a quick script or in excel. Check/compare to results from the NGS tools page. The transform steps and math will reveal where order of operations matter.
https://www.ngs.noaa.gov/ https://geodesy.noaa.gov/NCAT/ https://geodesy.noaa.gov/INFO/datums-transformations.shtml
In fact I go so far as to output SVGs with degrees values (degrees relative to the upper left point) and then there is a global scale factor for the final image to fit whatever size I want - so the image units are in real degrees - this makes life a lot easier.
After reading all the responsese here my argument would be that you should use whatever internal representation is most convenient programmatically - and then you expose in your API or UI or whatever a system based on other criteria (though it's hard to see how lon/lat would ever be sensible here). Your internal and external systems don't have to have any relation.
As you've deduced my problem space isn't too concerned with projections at the moment. Both precipitation and elevation data comes in a GeoTIFF (ie. lat/lon grid). In fact doing any kind of projections would distort by grid and greatly complicate my life :) But it's something I will keep in mind. When you start looking at large areas then you effectively have different data densities at different ends of the region and this is not great (poleward things have disproportionately more data). Thanks for the extra information and references - it may come in handy eventually.
The standard is X/Y+Spatial Reference. (the SR is usually out of band) If your spatial reference maps X to "latitude" and Y to "longitude", then so be it, but in general, I would expect a spatial reference which is applicable to an area that doesn't include the poles to map +X to East-ness and +Y to North-ness. (Spatial references near the poles get... interesting...)
If your data doesn't have a spatial reference, then you don't have data, you have numbers.
There are several reasons for this. First of all, there's the whole XY plane and all that. Secondly, there's also the fact that lat/lon/height coordinates, if you wish to preserve the right hand rule, translate to +north/+east/-up or north/east/down[0] coordinates, where elevations above sea level are negative, and the more you climb some mountain, the more negative your Z coordinate becomes. On the other hand, lon/lat/height becomes east/north/up, and the right hand rule is preserved.
Source: this is my day job.
Turns out, we did not pin the pyproj library [1] and they introduced a switch from lon-lat to lat-lon order, per default.
It was possible to retain the old behavior with `always_xy: bool = False`. I saw hundrets of similar reports, who knows how many users were effected. Conclusions, a) Always pin your dependencies, b) explicit is better than implicit.
Besides, I have a personal, subjective preference for lon-lat, but I understood the lat-lng order to be the officially accepted norm.
The basic motivation was that PROJ was changed to correctly follow the axis order of EPSG codes. Anyway, it was quite confusing at that time, but over the years working with geographical data made more sense to me and I am now always aware of the specific order.
See also an extended discussion here [2]
[1]: https://github.com/OSGeo/PROJ/pull/1182
[2]: https://pyproj4.github.io/pyproj/stable/gotchas.html#axis-or...
edit: it does seem like PROJ DID introduce a new header file with a new API[0] and eventually deprecated the older one sometime later, handling the transition much more gracefully. I guess pyproj didn't do the same thing?
[0]: https://proj.org/development/migration.html#api-migration
You need to investigate the reasons for a major version change before updating the dependency and running tests any time one occurs, to see if any documented behavior you are expecting has changed.
But a few weeks later, I love them. They are a great opportunity to learn how well a test suite is setup. How it can be improved, cleaned up, refactored, or just kept the same.
I get the order wrong when working with geojson with embarrassing frequency...
http://www.macmillandictionaryblog.com/a-hotchpotch-of-redup...
tik tik tik
Citation: https://en.m.wikipedia.org/wiki/Tik_Tik_Tik_(1981_film)
This is converted to latitude and longitude from GPS using the WGS-84 standard, at least for the western world. Russia uses the PZ-90 reference frame for GLONASS. China uses the BeiDou coordinate system. There's also an obfuscated latitude and longitude used by China for public consumption, GCJ-02. This introduces an error of 100 to 700 meters. Not that anyone is fooled; the obfuscation algorithm is known.
But everybody uses the same ECEF 3D coordinates, and combining satellite data is done in that frame. So if you need precise locations, there's something to be said for working in ECEF.
Imagine you are building an offshore wind turbine. You want 20m of clearance between the sea and turbine blade. That means 20m above highest possible tide. Tidal data is only available for a port 200 miles away and will be different for you based on local gravity. So you use modelling from satellite based gravity data to make an assumption. And then give instructions to a ship out at sea who has a contractual obligation to place the turbine within 30cm of the required position. Which coordinate system do you use? And when you are modelling a microwave link from that turbine to an onshore location on the horizon that is surveyed using a local datum what coordinate system do you use?
In reality geocentric coordinates are unlikely to be used. But maybe it would be easier if they could be. The world it not flat and it is not easily modelled as a sphere. A set of coordinates always carry with them a set of assumptions that may not work with your particular task. Geocentric coords can remove some of those assumptions.
I agree. When objects interact with each other, having everything as (x,y,z) makes many things a lot easier.
So in your example, ideally, you send the ship the (x,y,z) coordinates. Internally, we would have to worry about tides and figuring out exactly what the coordinates should be, but crew installing it would know exactly where to place it.
Furthermore there is the distinction between "geodetic" latitude ϕ (without qualification): the angle between the normal and the equatorial plane - this should be given with a specification of the ellipsoid and "geocentric" or "spherical" latitude θ (or ψ, q, ϕ′, ϕc, ϕg): the angle between the radius and the equatorial plane. (Figure below).
Quoting from https://en.wikipedia.org/wiki/Latitude :
"The importance of specifying the reference datum may be illustrated by a simple example. On the reference ellipsoid for WGS84, the centre of the Eiffel Tower has a geodetic latitude of 48° 51′ 29″ N, or 48.8583° N and longitude of 2° 17′ 40″ E or 2.2944°E. The same coordinates on the datum ED50 define a point on the ground which is 140 metres (460 feet) distant from the tower.[citation needed] A web search may produce several different values for the latitude of the tower; the reference ellipsoid is rarely specified."
Whereas confusing lat/lon order usually is noticed as a bug because some points end up in an ocean or close to the poles, use of the wrong datum (reference surface) leads to more subtle errors (as the above example shows) and is therefore more likely to go undetected. What I recommend is to use test cases with well-known points and check in your GIS processing pipelines that a few test locations are still where you expect them to be at certain check points in your process.
https://www.gim-international.com/content/article/european-d...
Toward the end is info on ED50's relationship to WGS-84.
> Commonly an ellipsoidal model is part of a more encompassing geodetic datum.
https://en.m.wikipedia.org/wiki/Earth_ellipsoid
A brief history of datum-geoid pairings can be found in the section Historical earth ellipsoids.
For WGS-84 datum+geoid, an authoritative reference: http://www.unoosa.org/pdf/icg/2012/template/WGS_84.pdf
Is negative longitude even legal?
Jokes aside, it is always (lat, lon). Latitude is a universal value, while longitude was not just about 100 years ago: every country had its own zero meridian. When finding coordinates we are first measuring a sun angle above the horizon at local noon, that gives us a latitude. Longitude is just a time difference between zero meridian noon and local noon.
And yes, negatives make sense and are "legal", by which I mean they pick out locations in a meaningful way and should not be considered out of bounds. What you probably mean is that they are not canonical, and by convention people usually wrap them to points within a certain range. Doing this wrong is a common source of bugs in maps.
Negative longitude, negative latitude and even latitude modulo above 90 degrees will produce a point on the globe, but library-wise I would not allow it to pass input validation.
(Needing to do a deeper dive into some of Leaflet's code at one point gave me a somewhat greater appreciation over why there is such disagreement between [lat, lon] and [lon, lat] formats. Abstractions are hard, and when you know you already need a crazy projection abstraction or three, sometimes the simplicity of [x, y, z] Euclidean approximations feels like "home" for as much as you can reason in it and expect the projection math to "just work" with it as long as you are consistent.)
For formats such as csv, parquet or a SQL database that store the names of fields only once, overhead is constant, regardless of number of items.
So, it only can be a problem for formats such as xml or json that repeat the names of fields in every record.
Those happen to be formats with variable record length, so you can’t index into such files; the only way to process them is in their entirety.
If so, and storage size is a problem, you can compress the files. Your typical LZW variant will, if the files are large enough, eventually encode both the “(lat=“ and “,lon=“ parts to single codes of (typically) 12 bits each. That will happen after the fifth occurrence of such strings, so fairly soon). That’s 24 bits of overhead per item. Significant, but if you use xml or json, chances are you’re already giving up way more by storing floating point values as text strings.
So, that leaves json or xml files that each store only a few items per file. With a typical file system block size of 8 kB, those already give up 4 kB on average per file.
I'm literally in the process of processing 100gb compressed spatial json and it's not enjoyable
1: I wasn’t able to find this in the main docs for some reason? Only the release notes. https://www.typescriptlang.org/docs/handbook/release-notes/t...
Lat Lon makes more sense when the programmer organizes the way they think about geography in a more astronomical or climate-centric way first, by sun exposure. The first thing you know when given Latitude is north/south hemisphere, what season the target is in, and roughly (although depending on land masses and bodies of water and terrain) what the climate is probably like.
Lat/Lon is the traditional and historical standard way of expressing location. Why are programmers treating it as if it's a new, unsettled question, and deciding for themselves which order to use for their software?
Interesting that both WMS and WFS changed to lat/long in later versions of their specs. Maybe more people could take the hint.
One nice feature with Kotlin is using extension functions and extension properties on type aliases. I use this a lot in my library. So, I can represent points using a DoubleArray, which is a specialized primitive array type.
I defined a typealias PointCoordinates = DoubleArray, and then have extension properties defined on like:
val PointCoordinates.latitude: Double get() = this[1]
The compiler inlines all of that of course so it's all simple array manipulation. But it looks like an object. And I get to avoid the longitude/latitude confusion. Another nice language feature that I use a lot is named parameters on functions. Nothing worse than somebody calling f(lat,lon) when they should have called f(lon,lat). Much less confusing if you call f(latitude: lat, longitude: lon).
Btw, give that you have a PointCoordinates type, why not f(p: PointCoordinates)?
You are right about the function call :-). Actually you can also do fun PointCoordinates.f() {...}.
The reason I have function calls with latitude and longitude in there as equivalents for their point coordinate variants is just convenience. If you have some other library using its own point representation, having to first convert to my representation before you can use my functions is a bit verbose. And of course, people into OO programming usually get a bit carried away reinventing their own Point classes. It's one of the reasons I stayed away from using object hierarchies in this library.
The geojson classes are an exception to this and were actually bolted on fairly recently so I can support geojson compatible serialization/deserialization.
"Geographical tradition favors lat, lon. Math and software prefer lon, lat."
But why does math and software prefer lon, lat? Unlike endianness, where it appears little-endian is the better choice at the hardware level, I'm drawing a blank why one ordering is better for computation.
But in math you care far more about labeling the angles correctly than about which order you list them in.
> Do you have a preference? Yes I do: longitude, latitude.
http://macwright.org/2016/07/15/longitude-latitude-is-the-ri...
The bullet points:
* Almost every geospatial format puts longitude first
* Almost all open source software uses longitude, latitude ordering
* longitude-first is the equivalent of XY ordering
You can align them by restoring the vowel length and writing "laatitude" & "longitude" :-)
is it:
[xmin ymin xmax ymax]
[xmin ymin width height]
[xcenter ycenter width height]
# all of the above but in normalized [0,1] not pixel coordinates
and so on and so forth and i swear i’ve seen at least a few deficient formats that use nonstandard (for image space) coordinate axes so the origin is somewhere else.[1] https://en.m.wikipedia.org/wiki/Earth-centered,_Earth-fixed_...
I had always thought math prefers lat, lon ...well not lat (which is the altitude angle) but polar angle. But anyway, this order: polar, azimuth. Turns out I have been getting all my spherical coordinates math from physics, which uses polar, azimuth. But math uses azimuth, polar.
https://en.wikipedia.org/wiki/Spherical_coordinate_system
But then again: Where does math even use spherical coordinates that is not physics related?
It never happens that you try to generate {X} from {Lon} alone.
def LatLon_to_GoogleTiles(lat, lon, zoom):
lat_rad = math.radians(lat)
n = 2.0 ** zoom
xtile = int((lon + 180.0) / 360.0 * n)
ytile = int((1.0 - math.log(math.tan(lat_rad) + (1 / math.cos(lat_rad))) / math.pi) / 2.0 * n)
return (xtile, ytile)Aside: If you are using a modern language (like C#) you can just use parameter labels and avoid this whole mess by being explicit each time. Underscores as separators in numeric literals are also pretty neat if you ever need to hard-code a scale or lat/lon for some reason.
Some of the libraries under complaint only support WGS84 (basically what anyone using GPS thinks of when they say lat/lon). If you have never seen a coordinate from anything other than GPS or Google Maps, then it would seem strange that someone would expect coordinates in x,y.
Other libraries support a wide variety, including projected (rather than geographic) coordinate systems where x,y is more appropriate (WebMercator, for example). Libraries like Google Maps never expose the underlying xy coordinates, but others will.
State plane coordinates, for example of widely-used xy system: https://en.m.wikipedia.org/wiki/State_Plane_Coordinate_Syste...
More info on projected/Cartesian coordinates vs geographic/spherical coordinates:
https://www.esri.com/arcgis-blog/products/arcgis-pro/mapping...
So, every time I get the lat/lon order wrong around here. I get a brief trip to Antarctica.
It's important when hacking this kind of data (or any data) to develop at least some sense for what it means. If there's an error in the data, you want to be able to think, wait, that isn't right, that's in the Atlantic someplace east of Cape Hatteras (or whatever).
And, of course, when using map products like USGS quads or UK Ordnance Survey maps we use those mapping agencies' coordinate systems, be they US State Plane projects, Universal Transverse Mercator, or whatever.
I inherited one app for USA use where the original developer decided the longitude values should be positive rather than negative. Wait, what? Kazakhstan? Must be wrong.
Like any physical measurement, lat/lon makes some kind of physical sense. Unlike many measurements, lat/lon has some constraints. For example you know a priori a latitude of +130° is bogus.
I always say "lat/lon", it sounds better in english. Just like click-clack, zig-zag, criss-cross, ding dong, king kong. It feels like one of these rules but I can't put my finger on it: https://www.bbc.com/culture/article/20160908-the-language-ru...
On the other hand, if thinking about them as x and y then x is longitude so it naturally comes first.
In the military I learned the rule lon then lat and was taught to think of an elevator: first you step sideways in to the elevator (lon), then you go up or down (lat).
"fi fy fo fum" "friend or foe?" etc
Why aren't we using some self-explanatory terms?
I propose "rotitude", "iclinitude". Guess which is which.
h/t https://www.geographyrealm.com/remember-difference-latitude-...
In any kind of graphic design work if you're communicating with printers, pre-press, etc. you say Width x Height. Like paper size. 8.5" x 11". But once in awhile, a client requests something that's described in height x width. Usually the giveaway is that billboards aren't 17 feet tall.
But in some cases, if they're from the South, I know I have to ask them three times to make sure they're telling me width and height. The third time they'll get that width is the left to right size.
To me that would make (lon,lat) preferable, then? Longitude would be the width/left-right/x-axis coordinate, and latitude be the height/up-down/y-axis coordinate?
Or maybe I misunderstood, and you just highlighted that we every discipline should have it’s standard and as opposed to stating that geographical coordinates should match the printing and other domains?
It is common to see lat/long, but in fairness long/lat makes more sense as it reflects x/y axis.
– Some like to think like a matrix then, usually with row, column. – Some like to keep the continuous convention. – Some like to split the difference.
Which then leads to the confusion when doing spatial stuff, as it swaps between a lot of JS libraries (for showing) and backend systems (for querying)
What does this mean?
So to this day in UE5 y is depth and z is height. This causes fun inconsistencies with all other 3D apps.
> Do you have a preference? > Yes I do: longitude, latitude.
The author is just wrong here... and is writing this post to try to pretend that there is more difference of opinion than there actually is.
Geographical tradition and the English language. If you say "longitude and latitude", it sounds off, like "white and black" rather than "black and white".
> There's some consensus growing around longitude, latitude
Naturally, some dweebs trying to "fix" things get it backwards.
lon, lat is x, y.
Who says "y, x"?
Row-major 2D arrays. Matrix indices in math.