I Hate Coordinate Systems
ihatecoordinatesystems.com
ihatecoordinatesystems.com
Reality is that these are expensive errors that can be avoided by systematic planning but made far too easy by default software options. I've seen weeks/hundreds of thousands of dollars wasted by proceeding with data analysis without properly considering the coordinate reference system.
If spatial accuracy is a concern and
- your data is vector-based lines or a polygons, there is no guarantee that the edges between your vertices will follow the same trajectory in a different coordinate system. This means that the spatial relationship (intersection, overlap, etc) between two geographic objects depends on the coordinate system and the relative density of points.
- your data is raster-based, you need to resample pixels values to translate between coordinate systems. If your pixels represent absolute/measured values (eg population), you need to consider this carefully.
- In both vector and raster, you need to deal with dateline and pole issues. The earth is not a cartesian plane.
- In both cases, you also need to consider more than the projection. You also deal with datums which define the relationship between the actual earth surface and the theoretical sphere/spheroid the projections are based on. Get this wrong and your results might "look" OK but be meters off - you might not see it visually but it will cause problems for high-precision analysis.
One thing about this topic that makes it hard to learn is software ergonomics. It seems like a lot of tools can work with GeoJSON now, and as I understand it GeoJSON has simply declared that there is only one coordinate system and every file uses that one. Declaring a different CRS is not allowed in the standard. However, ESRI ArcGIS will emit GeoJSON with any CRS you want. In fact if you don't tell it specifically to use the GeoJSON standard, it will instead emit GeoJSON in EPSG 3857, which is not just irritating but plainly incorrect. It further confuses the issue that the 3857 system has six other alternate names, each seemingly as well known as any of the others.
It doesn't help that geopandas will cheerfully perform a spatial join of two dataframes despite the fact that it knows full well that the two frames have incompatible coordinate reference systems. It will warn about this condition but it will do the join anyway and you might not see the warning after a million lines of console spew.
a) have the software (silently) transform your data, making decisions on your behalf about which are the source and destination projections, datum transforms, raster resampling, line densification, and precision.
PRO: easy, CON: potential poor performance, accuracy.
b) fail because the coordinate references systems don't match.
PRO: logical, type-safe, CON: Comparing coordinate systems is not a solved problem. You can have two identical (or practically identical) systems that are not equal by their representation or your programming language semantics.
c) try to naively attempt the spatial analysis in 2D cartesian space.
PRO: does what it says, leaves the responsibility to the programmer. CON: does what it says, leaves the responsibility to the programmer.
I've seen justification for all three approaches but no obvious solution. I tend to go with c) ala geopandas since ultimately the responsibility lies with the person building the system.
There is no harm done by b), there will never be a costly mistake. If the programmer has to deal with it anyways, at least make them very aware of the fact, they can then still decide to perform c).
I think this is a huge weakness of Pandas. I have to put “errors=raise” all over the place, although not many functions have that parameter.
GIS systems are an area where software and the physical world can meet in ways many devs don’t appreciate.
Also workmanager aka workmangler was known for sending linemen (engineers in BT speak) to the wrong place and also sending multiple teams to the same fault
When you increase bad inputs by 1000x, the magic of scalable cloud infrastructure multiplies your mistakes for you automatically.
I think just about every field in Computer Science has these kinds of problems though, where people learn just enough to be dangerous.
E.g.: the default sRGB colour space used by typical computers is non-linear, so you can't interpolate using naive algebra. You should convert to linear light, interpolate, then convert back to sRGB with the original gamma curve.
Practically nobody does this.
Even Adobe PhotoShop has this feature off by default which is just insane.
Just as with geospatial mappings, there are further nuances to imaging colour spaces. E.g.: Most colour spaces are designed to match some phosphor or LED colour, and do not match the human eye's response curves. So almost any "maths" you perform on almost any colour space, even in linear light will introduce colour shifts or other artefacts. E.g.: changing intensity, upscaling, downscaling, blending, etc...
A much better colour space would be to use something like ICtCp, which is designed to match the response of the human eye, so that the "coordinate system" would map better to the actual responses of the rods and cones: https://en.wikipedia.org/wiki/ICtCp
Note how the map of the colours is smooth, because it allocates "coordinate vector bits" to perceptual colours evenly.
This is one of the key features of Dolby Vision: https://professional.dolby.com/siteassets/pdfs/ictcp_dolbywh...
(Dolby is just about the only organisation that gets this stuff even vaguely right.)
All of the above issues can turn up in simple Long/Lat coordinates. There's always some idiot that ignores the fact that the coordinate density changes with location, or that the cells aren't even rectangles near the poles, or that interpolation is not trivial, etc...
The next pain point has got to be China's insane "GCJ-02" obfuscated coordinate system, as alluded to and linked on this site. I've had a lot of trouble getting basically anything GPS-related to spit out meaningful things while in that country (more accurately, matching basically anything up with maps while there). While it has been reverse-engineered, you always get to wonder whether the authorities are going to come after you for having GPS data that's too accurate...
Coordinate systems are hard. GIS stuff is hard. I'm glad this website exists. Even if it's hard for people to identify the problem, this site at least makes one aware of the problems in the first place.
Given that all of China's potential enemies have detailed satellite maps of the region and aren't in the slightest bit inconvenienced in their targeting accuracy because of GCJ-02, that's obviously false.
Clearly, GCJ-02 is just simple, ordinary corruption, the type endemic to China. Someone convinced some politician with a bag of money to keep a legally mandated monopoly on mapping, locking out foreign competitors.
PS: Japan does similar things, where for example Google Maps refuses to "download" maps of Japan because by law they are not allowed to make their own maps of Japan and must license the data from a local provider. That local provider does not allow offline use.
The world of mapping is nuts.
(that the licensed data they use has some restrictions is clear enough)
https://www.reddit.com/r/japan/comments/dt4pe7/google_maps_a...
What makes the situation even funnier is that Google-Earth-style satellite images were (and still are?) not regulated as maps, and they're free to be published with unobstructed WGS-84 coordinates. Only the maps are regulated to use GCJ-02. If you use a standard GPS receiver, your location will be perfectly normal in satellite view, until you switch the display to map view. Claiming it can protect "national security" is just fooling oneself.
Odd edge cases are the default state of reality for geospatial unless you are extremely careful. Even if you are diligent and assume a global high-precision ellipsoid as your Earth model, you still have to ensure that the computational geometry is correct in that context for every possible use case. Operations on real surfaces are difficult to implement on discrete computers.
As a simple example, correct ellipsoid computation in double precision sometimes can't even be computed in quad precision, never mind double, yet most efforts at computational geometry limit themselves to double precision because that is what computers support natively. Manipulating relationships in real-world coordinate systems is not for amateurs.
1: https://drive.google.com/file/d/1Fw5SdZ-aAiHrZERnIkVgll_OFnt...
The core of them mostly do the thing they claim to do, but if you feed them data that's just slightly off, then it'll break in interesting ways.
Speaking based on a lot of experience[1]. Nothing in the geospatial or environmental data world is easy and there will always be an unexpected problem lurking right behind the corner, regardless of how many of them you've already fixed or worked around.
Still, the complexity of the problem space also makes it fascinating. As an example, the definition and measurement of something that's seemingly very simple: mean seal level is actually tremendously complicated if you think about it. The Wikipedia article talks about averaging over decades of measurements to get it right for example.
[1] I'm a part of the team behind https://data.planetos.com/datasets
A challenge of open source software is that it largely only gets created when the technical complexity and expertise barrier is low enough. Above that threshold, the small number of people capable of contributing combined with the large number of man-hours required for a correct implementation is beyond the resources typically available to such a project. Geospatial is a good example of this pattern (database engines are another).
[Edit] More informed description: https://en.wikipedia.org/wiki/Word_(computer_architecture)
https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/Tutorials/pd...
https://en.wikipedia.org/wiki/Earth-centered_inertial vs https://en.wikipedia.org/wiki/ECEF
Lat/Lon or Lon/Lat, and what about altitude? especially when libraries have parameters like x, y, z and you have to triple-check which value is going into which vaguely named, not well documented, field.
Because there are different conventions on which value goes to which depending on your background.
I thought the Open Geospatial Consortium's standards would reflect dominant practice, that turns out to have been the wrong assumption [1]
The only geospatial software I've used is Proj4J, which normalizes with a function called toENU.
I guess I've only encountered weird stuff then.
[1]: https://lists.opengeospatial.org/pipermail/coordtran.wg/2006...
I was quite surprised to find that while it is straightforward to go from WGS84 to ECEF with a closed form, the other way, from ECEF to WGS84, needs to be computed iteratively [1] and is not trivial to find.
[1] https://en.wikipedia.org/wiki/Geographic_coordinate_conversi...
There's nothing like telling your 6-figure CNC or multi-axis robot to make a piece of carbide occupy some space where you currently have precision-ground hardened steel because someone left a G92 somewhere you didn't expect it to be. Though I suppose that errors can be at least that expensive in GIS if you're quoting civil engineering or real estate...
This Phd comic is pretty acurate about the situation: http://phdcomics.com/comics.php?f=1689
Now imagine being a newcomer with neither programming experience nor domain specific knowledge and asked to add some feature to such a legacy codebase. This is the standard case in science.
In my first job I updated someones (doing a PHD in fluid mixing) Fortran code.
The original software to run an experimental rig just put up a ? prompt and you typed numbers in to drive the experiment.
You had to memorise which number was used for what and at which point you had reached.
I updated it to prompt the user and at every step display what options where available and also allowed you to go back a step.
I even went as far as to use Mixed Case Hollerith segments!
Apparently they're used to just receiving print-outs shudders
But in all seriousness the domain name is channeling an attitude felt by generations of GIS practitioners. I don’t really know why it’s on HN though...
And it's probably an alright source for people whose geo data isn't looking right.
On rare occasion a GIS tool will completely balk at the data being CRS.Simple
Case in point: https://web.archive.org/web/20171201234812/https://consumeri...
I had to do this for the backend of a game I'm building - built my own geohash so I could add some optimizations I wanted (like storing nearby hashes for certain nodes etc).
Created some fun graphics while testing the bounding box queries, like:
https://jvm-gaming.org/uploads/default/optimized/2X/d/d7c489...
Your dataset is tilted 90° and in some other part of the globe: you probably swapped latitude and longitude.
Tip: latitude sounds like "altitude" so it has to be the y coordinate
As a French nitpick, the "sideways axis" is actually not going sideways, but pointing right at us :)
The core of the problem is that the system talks about "lines" too much. In regular math, we have axes, but we don't think much about a point being at the "intersection of the x=3 line and the y=5 line", it's just "horizontally 3 and vertically 5". But in GIS we visualize a full grid, with "lines of latitude" instead of "lateral deviation".
Mentioned nowhere is that you need WGS 1984 in the mix or you get nothing. That was fun.
I get all the gotchas, but formula is much easier for me to get my head around rather than these articles which are centered around me having to learn a lot of terminology just to be able to do a transformation between coordinate systems. Even if that formula was accompanied with a correction table for particular use cases.
Everything is an approximation.
Edit: if you can put either of those extraordinary places in touch with me, that's fine also.
The upshot of Snyder is that it includes -samples- for everything, which is really useful if you ever wind up having to deal with an Albers Conic over 3 states in the US, that also is using an elipsoid typically used in India.
Oh, also it's 2010 and you can't afford actual GIS tools. You have Google Earth, Visual Studio, AutoCAD, and Microstation. Good Luck.
I just finished implementing enough of the WMTS spec interact with the one provider I'm using so far (UK ordinance survey). The only library I could find to help that works on Android was proj4j, which I'm using to handle converting points to different CRSs.
I'm making incredibly rookie mistakes like just realizing I need to project vector data into the same crs as the raster base map.
I want to be able to transparently support changing the base map to one with a different crs and lines and points recorded in the previous crs show up in the "right places", but I can't figure out how that's possible. I think I've seen other apps do it.