Timeline for PostGIS <-> operator does not return true distance
Current License: CC BY-SA 3.0
15 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Aug 7, 2018 at 18:07 | history | tweeted | twitter.com/StackGIS/status/1026892544280551425 | ||
Jul 11, 2017 at 12:14 | comment | added | coding_bird | Let us continue this discussion in chat. | |
Jul 11, 2017 at 12:13 | history | edited | coding_bird | CC BY-SA 3.0 |
changed version of docs
|
Jul 11, 2017 at 12:01 | comment | added | coding_bird | OK. It seems that PostGIS 2.2.2 does not use "real KNN distance" - whereas 2.3.2 does support it. | |
Jul 11, 2017 at 11:55 | comment | added | John Powell | Perhaps excessive information, but: PostgreSQL 9.5.6 on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 5.3.1-14ubuntu2) 5.3.1 20160413, 64-bit and POSTGIS="2.3.2 r15302" GEOS="3.5.0-CAPI-1.9.0 r4084" PROJ="Rel. 4.9.2, 08 September 2015" GDAL="GDAL 2.1.3, released 2017/20/01" LIBXML="2.9.3" LIBJSON="0.11.99" RASTER, ie, 9.5.6 and 2.3.2 :-) I have also tried on 9.4 and 9.6, with 2.2 and 2.3, and get the same, ie, correct result. Very bizarre. | |
Jul 11, 2017 at 11:53 | history | edited | coding_bird |
edited tags
|
|
Jul 11, 2017 at 11:48 | comment | added | coding_bird | When I put the ASC I get the same result as before. Which Postgres/PostGIS version are you using? | |
Jul 11, 2017 at 11:44 | comment | added | John Powell | I can't. When I run your code, I get green first and then blue, as you would expect. What happens if you put ASC at the end of the ORDER BY. I realize that it shouldn't be the case, but just to check. | |
Jul 11, 2017 at 11:33 | comment | added | coding_bird | @JohnPowellakaBarça I updated my question. Can you explain this behavior of PostGIS? Thanks :-) | |
Jul 11, 2017 at 11:32 | history | edited | coding_bird | CC BY-SA 3.0 |
provided minimal example
|
Jul 11, 2017 at 7:40 | comment | added | John Powell | Well, you say the answer is incorrect, but it is impossible for us to test without some geometries and the expected results. The query itself looks ok. | |
Jul 11, 2017 at 7:36 | comment | added | coding_bird | @JohnPowellakaBarça do you need more information? Which numbers shall I provide? | |
Jul 10, 2017 at 15:08 | comment | added | tilt |
Can you add a field ST_Distance(ST_Point(1,2)::geography, ST_Centroid(my_polygons.geom)) AS cent_distance to be sure of this?
|
|
Jul 10, 2017 at 12:56 | comment | added | John Powell | The <-> operator is finding the closest polygon by the kNN distance and ordering results accordingly, but your actual distance metric is being determined by ST_Distance, which will definitely return the distance to the nearest point on exterior of the polygon, not the centroid. It is a bit hard to tell without some raw numbers, though. | |
Jul 10, 2017 at 11:50 | history | asked | coding_bird | CC BY-SA 3.0 |