TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

The lat/lon floating point delusion

149 pointsby eaguyhnalmost 6 years ago

27 comments

jjoonathanalmost 6 years ago
Yes, why don&#x27;t people spend their time doing the extra work to figure out the exact number of meaningful digits in their measurements when the defaults work just fine for their non-scientific, non-metrological purposes?<p>A mystery for the ages.
评论 #20654928 未加载
评论 #20654884 未加载
评论 #20654770 未加载
评论 #20654658 未加载
dfrankealmost 6 years ago
People have this idea that when you take a measurement, you have so-and-so number of significant figures that are probably correct and the rest are just pure noise. But that&#x27;s not how measurement error works. In the real world, physical measurement errors are more-or-less normally distributed (we don&#x27;t have to argue about the &quot;more-or-less&quot; part because my argument here holds for any distribution other than a uniform one). Let&#x27;s say your measurement gives you a latitude of 45.73490534578° with a standard deviation of 0.00001° (that&#x27;s about 11 meters). Those last few digits of your measurement are almost certain to be wrong. But does that make them meaningless? No! Because if your measurements are unbiased, then slightly more than half the time, 45.73490534578° is still going to be closer to the true value than 45.7349053457° is. By performing significant figure rounding, you aren&#x27;t throwing <i>very much</i> information, you may not be throwing away any information you care about, but you are nonetheless throwing away information.
评论 #20655147 未加载
评论 #20656037 未加载
评论 #20656547 未加载
评论 #20655590 未加载
评论 #20655759 未加载
wpietrialmost 6 years ago
In contrast to his 4-digits-are-fine notions, let me offer a counterexample: <a href="http:&#x2F;&#x2F;scissor.com&#x2F;transient&#x2F;destination_heatmap&#x2F;" rel="nofollow">http:&#x2F;&#x2F;scissor.com&#x2F;transient&#x2F;destination_heatmap&#x2F;</a><p>I am working on a Twitter bot called @sfships, which monitors the comings and goings of large ships in the San Francisco Bay: <a href="https:&#x2F;&#x2F;twitter.com&#x2F;sfships" rel="nofollow">https:&#x2F;&#x2F;twitter.com&#x2F;sfships</a><p>As part of that, I generated the above map from AIS data. [1] It&#x27;s basically where ships stop. If you zoom in on the San Francisco waterfront, you will see a grid of dots. That&#x27;s because the AIS protocol stores lat&#x2F;lon as minutes&#x2F;10000 [2], throwing away more detailed information.<p>This is adequate for its initial intended purpose, which is putting ships on radaresque displays so that ships don&#x27;t hit one another, etc. But it produces all sorts of artifacts and issues when one tries to use the data more broadly.<p>And in case anybody is interested in playing with this, I have written a python parser for AIS data with a bunch of Unixy command line tools, including one that just turns the weird 90s protocol into more modern JSON: <a href="https:&#x2F;&#x2F;github.com&#x2F;wpietri&#x2F;simpleais" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;wpietri&#x2F;simpleais</a><p>[1] <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Automatic_identification_system" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Automatic_identification_syste...</a><p>[2] <a href="https:&#x2F;&#x2F;gpsd.gitlab.io&#x2F;gpsd&#x2F;AIVDM.html#_types_1_2_and_3_position_report_class_a" rel="nofollow">https:&#x2F;&#x2F;gpsd.gitlab.io&#x2F;gpsd&#x2F;AIVDM.html#_types_1_2_and_3_posi...</a>
评论 #20656906 未加载
评论 #20655824 未加载
评论 #20660267 未加载
评论 #20657389 未加载
remusalmost 6 years ago
I find it hard to get that worked up about this. The positions are accurate at least, and if you&#x27;re really so hard up for space that saving a couple of digits is going to make all the difference then you can think about it for 5 mins and choose a precision&#x2F;storage trade off that&#x27;s appropriate for you.
评论 #20654436 未加载
cafardalmost 6 years ago
Not just lat&#x2F;lon. I find myself amused when The Washington Post&#x27;s education columnist Jay Matthews--quite a sharp guy from all I can tell--runs his high school &quot;challenge index&quot; (AP tests taken &#x2F; size of graduating class) out to six decimal points for small schools. Somebody give that man a slide rule.
评论 #20654603 未加载
评论 #20655039 未加载
评论 #20655849 未加载
评论 #20654742 未加载
janpotalmost 6 years ago
It doesn&#x27;t matter how precise the value is, as long as it&#x27;s precise enough for your use-case and as long as machines are handling it. If the value is displayed in a UI and it&#x27;s rounded off to a reasonable decimal there, I don&#x27;t see the point why you would get so worked up about it.<p>I&#x27;m sure my thermostat internal temperature representation is way more precise than the 0.5 degrees precision it&#x27;s showing on the display.
评论 #20654749 未加载
kbutleralmost 6 years ago
The author also ignores the fact that the distance associated with a degree of longitude changes dramatically as you go from the equator (69m&#x2F;111km) to the poles (0) - roughly as a cosine. So the number of decimal places of longitude should shrink as you get further from the equator.<p><a href="https:&#x2F;&#x2F;www.thoughtco.com&#x2F;degree-of-latitude-and-longitude-distance-4070616" rel="nofollow">https:&#x2F;&#x2F;www.thoughtco.com&#x2F;degree-of-latitude-and-longitude-d...</a><p>&quot;At 40 degrees north or south, the distance between a degree of longitude is 53 miles (85 kilometers).&quot;<p>So while it&#x27;s appropriate for Melbourne (37.8S) to use (very slightly) lower precision than Sydney (33.9S), they&#x27;re both using too many digits.
评论 #20654612 未加载
评论 #20654616 未加载
sccxyalmost 6 years ago
I usually go with 6 decimal places.<p>Geojson format advises it also<p><a href="https:&#x2F;&#x2F;tools.ietf.org&#x2F;html&#x2F;rfc7946#section-11.2" rel="nofollow">https:&#x2F;&#x2F;tools.ietf.org&#x2F;html&#x2F;rfc7946#section-11.2</a>
评论 #20654611 未加载
not_a_cop75almost 6 years ago
Agreement on the decimal places. But honestly, why would you commit to using GPS as the end means of locating in Australia when you&#x27;ll be noticeable off in 20 years and outright inaccurate in 100?<p><a href="https:&#x2F;&#x2F;www.nationalgeographic.com&#x2F;news&#x2F;2016&#x2F;09&#x2F;australia-moves-gps-coordinates-adjusted-continental-drift&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.nationalgeographic.com&#x2F;news&#x2F;2016&#x2F;09&#x2F;australia-mo...</a>
评论 #20655037 未加载
评论 #20655060 未加载
评论 #20659345 未加载
jandrewrogersalmost 6 years ago
Professional geospatial systems frequently use fixed point internally but export floating point for convenience. The Internet treats all geospatial as floating point but positional measurement systems and mapping base layers often come from fixed point data models.<p>Many of the underlying fixed point systems are designed for meter precision, with some newer systems going down to a centimeter. As a practical matter, repeatable positioning on the Earth&#x27;s surface becomes difficult below 10 centimeters of precision, so centimeter precision is widely viewed as the physics floor.
评论 #20658016 未加载
kraphtalmost 6 years ago
Did the author think about the implementation? If we assign semantic meaning to the number of decimal points, now we also need to store the number of significant digits side by side with the actual number. We shouldn&#x27;t round off internally because we might use it in as an intermediate result in a calculation.
评论 #20654336 未加载
评论 #20654296 未加载
评论 #20654678 未加载
moron4hirealmost 6 years ago
I recently ran into a weird error concerning Lat&#x2F;Lngs and floating point numbers. Google has a service for retrieving imagery from Maps, and you can even request that imagery have certain paths drawn on it. You encode those paths as part of your request URI, but if you have a lot of points, you could end up exceeding their maximum URI length restriction. So they also define a hashing system for compressing those points into a single value, which is defined here: <a href="https:&#x2F;&#x2F;developers.google.com&#x2F;maps&#x2F;documentation&#x2F;utilities&#x2F;polylinealgorithm" rel="nofollow">https:&#x2F;&#x2F;developers.google.com&#x2F;maps&#x2F;documentation&#x2F;utilities&#x2F;p...</a><p>One of the things they don&#x27;t mention is that the rounding step does not work as <i>they</i> expect for single-precision floats. You have to use double-precision floats to get the same results that they are demonstrating in the example.<p>They are asking for 5 values to the right of decimal points, which, with the maximum of 3 digits to the left of the decimal point, means a total of 8 significant digits. Single-precision floats should be good to 9 digits, but the rounding step is off by one when using singles.<p>The solution was to cast singles to doubles before performing the rounding. Which seems absurd.<p>Single-precision floats should be enough precision for lat&#x2F;lngs anywhere on the Earth, for everything other than some applications in commercial-grade surveying. And if that is the job you&#x27;re doing, you shouldn&#x27;t be using Google Maps.
thelittlenagalmost 6 years ago
These kinds of issues are what we&#x27;ve solved at QALocate.<p>There are a number of different issues here, which I think are only partly explored through the article.<p>Let&#x27;s take as given that you need to direct a person some place. In the article, they are directing someone to a restaurant. But this gets complicate fast. Is this person a patron rather than, say, a deliver driver there to pick up an order, or a plumber there to fix and appliance, or an inspector there to observe the kitchens, or ...?<p>By using a lat&#x2F;long, or any geo-coordinate, we lose the human-value of context. Each of the folks I list above has a very different place they potentially need to navigate to. And even if their destination is the same, the routes they took may NOT have been. Where they park, or were dropped by ride share, and which doors they use are also influenced by their role.<p>Using a geo-coordinate to drops the rich meaning that humans in all their roles require. A better solution is to use a real identity and then, when and where coordinates are needed, derive them based on the persons role, whether it be patron, plumber, or paramedic. As roles change, or as the structure itself changes, then directions change to meet them. I find this a much richer solution than just blindly telling my maps app to direct me to some GPS location.<p>Another issue hinted at but not deeply explored is that often what we want to specify is a region or volume, not a coordinate. Things in the real world consume volume. Coordinates are idealized points and do not. This may seem a trite observation, yet, the majority of our tools think in terms of points. With the rise of autonomous vehicles, especially drone delivery, we need to move towards representations of regions and&#x2F;or volumes, depending on needs. I&#x27;m not convinced that geopolys are quite right for this task and instead we need something that is comfortable with the fuzzy and complicated boundaries humans have to deal with.<p>[1] <a href="http:&#x2F;&#x2F;www.qalocate.com" rel="nofollow">http:&#x2F;&#x2F;www.qalocate.com</a>
评论 #20656202 未加载
kazinatoralmost 6 years ago
I think the issue is that people don&#x27;t have an good intuition for how many digits past the decimal point are relevant in latitude and longitude. &quot;42 degrees north&quot; is obviously imprecise. 42.123456 is precise down to a millionth of a degree; but if you wake me up in the middle of the night and ask me how long is one millionth of a degree of latitude at sea level, I wouldn&#x27;t just be able to blurt out the answer.<p>Turns out it&#x27;s about 11 cm.<p>A millionth of a degree is about 1.75E-8 radians. For small degree values, sin(x) = x, so we can just multiply that figure directly by the radius: ~ 6400000 m * 1.75E-8 = 0.112 m.
mangecoeuralmost 6 years ago
On the flip side - who cares? It&#x27;s just a question of shunting data around - ok someone could add a format specifier somewhere and it would be neater. But there&#x27;s no particular harm in it either.
评论 #20654680 未加载
评论 #20654746 未加载
alkonautalmost 6 years ago
The presentation is just lazy and javascript defaults to double. No mystery.<p>You can use digits to indicate accuracy but if you don’t know whether the measurement stored as a double is accurate to 2, 4 or 12 decimals then you can’t really do much in presentation. The reader has to interpret the number. Usually the reader doesn’t care much about accuracy, and simply copies the numbers to another system. The coordinates with full double precision is then basically a machine readable format.
ellisvalmost 6 years ago
&gt; Popping those long coordinates into Google Earth, it looks like the georeferencing puts the point somewhere on ILI&#x27;s back wall<p>Perhaps the Google Earth image is &quot;wrong&quot;. Stitching aerial and satellite images together and aligning every pixel to the exact geo-location isn&#x27;t as simple as it sounds -- especially given that the ground shifts over time.
评论 #20654815 未加载
rurbanalmost 6 years ago
I could explain this. Internally all those coordinates are stored as double (not long double). The precision of a double is max 15-17 digits. Usually it&#x27;s very inprecise though. But not too imprecise, because tiny errors could lead to very costly mistakes. my biggest did cost ~40.000, wrong after the third digit. 30cm. You might remember the financial stories on microdiffs with improper arith. That why one of the most important lessons I told my students was precision and it&#x27;s limits. Esp. when zooming in.<p>CAD&#x2F;GIS system round to the default vsprint %f precision which is 6. They could use a zoom dependent number but nobody would do that, they would laugh at you. It&#x27;s not a delusion, it&#x27;s industry practise. If you have better precision, you stick to it.
parliament32almost 6 years ago
lat&#x2F;lon kinda sucks because of the different notations (degrees with decimals? degrees and minutes with decimals? degrees and minutes and seconds with decimals?) and because of the way 0.1 degrees is a different amount of distance based on where you are on the earth.<p>UTM is better in every way, and already used on most modern hiking and topo maps.<p><a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Universal_Transverse_Mercator_coordinate_system" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Universal_Transverse_Mercator_...</a>
评论 #20667475 未加载
donarbalmost 6 years ago
I&#x27;ve been working with the AWS Textract, it scans image files and returns the coordinates of the scanned text. The coordinates are percentages of the width&#x2F;height of the image where one edge is 0.0 and the opposite edge is 1.0. The software returns numbers like &quot;left = 0.3140530586242676&quot;, which means that the text&#x27;s left coordinate is 31% from the edge. This is providing sub-pixel precision for 150 dpi documents.
danmgalmost 6 years ago
Users don&#x27;t usually care about raw lat&#x2F;lon. If you want to display them as an approximate so you can tell them apart as some kind of logging output do something like &quot;(%+07.4f,%+07.4f)&quot;.
bytematicalmost 6 years ago
What about future GIs programs that can handle these digits, should we not futureproof anything that doesn&#x27;t exactly utilize it today?
评论 #20656322 未加载
评论 #20655383 未加载
ivanhoealmost 6 years ago
Does anyone here know what&#x27;s the actual precision that we can get by the available equipment?
评论 #20654767 未加载
评论 #20654655 未加载
评论 #20654661 未加载
itrootalmost 6 years ago
Ugh. It&#x27;s better to use geohash almost everywhere. It solves this and many other problems (lat&#x2F;lon ordering), etc..
cojxdalmost 6 years ago
When you completely run out of things to complain about.
评论 #20654383 未加载
评论 #20654374 未加载
评论 #20656077 未加载
michael_finealmost 6 years ago
Edit: This is what I get for only skimming the article. Ignore
评论 #20654462 未加载
评论 #20655891 未加载
knolaxalmost 6 years ago
As far as I know sig figs aren&#x27;t a primitive type in most languages so the author&#x27;s point is moot.