# Question about distance from node to mark it as complete

(You can delete this comment, as I don’t like comments on Wikis) but are you certain it’s 25 m?? That seems … much further than my experience dictates. In most wide 4 lane roads, I will miss nodes in the corners, fairly consistently. I would have guessed 25 feet, not 82!

I have been tempted to make the same comment. There have been times I knew I was closer, but I then thought, “Maybe it’s the mystery of GPS drift? Or because I wear my Garmin on my left wrist?”

I think it’s 25m

``````ST_DWITHIN(geog, path.geog, 25)
``````

The ST_DWITHIN documentation says

For geography units are in meters and measurement is defaulted to `use_spheroid` =true, for faster check, `use_spheroid` =false to measure along sphere.

Maybe the query isn’t doing what I think it is since I’m not setting `use_spheroid` to false.

1 Like

Wow, that page is hard to make sense of.

Kudos to you James.

What SRID are you using James? the “distance” function is actually using SRID unit (treat SRID and EPSG as the same thing) and so technically you can’t assume the units are metre (but they probably are). Also, by setting the default of use_spheroid to true you are getting a more accurate calculation of distance. WGS84 is PROBABLY the spheroid you are using… the world is not flat and it is not a sphere (if it was either of these things all our lives would be much simpler). setting use_spheroid to FALSE would be faster, because the maths just assume a perfect sphere but it would be less accurate. So, the answer to whether your query is correctly calculating <25m distance will have more to do with what coordinate system and units of SRID you are using than setting use_spheroid to false. Just leave it TRUE - if you really want to be strict with 25m

Sorry, I’m not an expert - perhaps I know a dangerous amount - enough to think that I know what i’m talking about.

1 Like

If anyone is reading this, I’ve worked out you’re probably using GEOGRAPHY (ie Ellipsoidal spatial data types), therefore PostGIS defaults to metres (because angular units are a pain) - so after all that James, your query is correct and you can ignore what I said.

EXCEPT… setting use_spheroid to false will speed things up, and really over a few kilometres of a run the difference between a perfect sphere and the WSG84 spheroid are tiny, and so if you can live with a few centimetres inaccuracy, your code will run really quite a lot faster.

ST_DWITHIN(geog, path.geog, 25, false)

Chapter 4. Using PostGIS: Data Management and Queries - section 4.2.3.1

1 Like