[postgis-devel] KNN <#> Operator - odd results

maplabs at light42.com maplabs at light42.com
Wed Oct 26 22:10:20 PDT 2011


On Wed, 26 Oct 2011 15:11:50 -0700, Paul Ramsey
  wrote:
> Rather than eyeballing,
>
> select boxes <#> point, st_distance(st_envelope(boxes), point) from
> boxes order by boxes <#> point;
>

ok - no bug, it seems .. the results came back in the same order as 
shown in the slide,
(with one exception.. 1 and 2 are reversed. But the difference in 
distance is tiny... 
I have this SRS re-projection in their, which makes for a little bit of 
leeway for unexpected results)
--------------------------------------------------------------------------------------------------------------------------

select
 p.gid,
 st_transform( p.the_geom, 3310) <#> 
st_transform(st_geomfromewkt('SRID=4326;POINT(-121.935897 
37.702063)'),3310) as r_dist,
 st_distance(
     st_transform( st_envelope( p.the_geom ), 3310),
     st_transform(st_geomfromewkt('SRID=4326;POINT(-121.935897 
37.702063)'),3310)
   ) as dist
from
  parcels_alameda_2010_4326_tiny_rects p
order by
  st_transform( p.the_geom, 3310) <#> 
st_transform(st_geomfromewkt('SRID=4326;POINT(-121.935897 
37.702063)'),3310);
 
  gid   |      r_dist      |       dist       
--------+------------------+------------------
 373570 |         26.90625 | 27.8823330630699
 372308 |         26.96875 | 28.1630677591774
   2460 | 29.6516027316512 | 30.9251794852865
   2463 | 34.1303655297785 | 35.3354873128846
 373609 | 36.4721542116299 | 39.6772912792698
 372290 |        45.203125 | 45.3893629119042
 372289 |         45.59375 | 49.2488105444745
 239913 | 48.1751085075261 | 50.2677507004797
 228173 | 59.0255919734186 | 59.5415355177686
 370498 |         62.65625 | 66.5620931647126
(10 rows)

  >
> On Wed, Oct 26, 2011 at 2:00 PM,  <maplabs at light42.com> wrote:
> > Hi All -
> >
> >   the distances generated by the <#> operator, shown on
> >
> >       http://download.osgeo.org/postgis/knn_misc/knn_rbox_ansF.png
> >
> > seemed odd to me.. now I could have made a mistake - but the session is
> > transcribed
> > so it is repeatable... 
> >   an informal double-check just now gave me  these *actual* distances
> > (in fake pixel units of the screenshot, blown up twice)
> >
> >   distance order             pixel distance     
> should-be order
> >
> >     
> 1                                 
> 50                      2
> >
> >     
> 2                                 
> 60                      4
> >
> >     
> 3                                 
> 47                      1
> >
> >     
> 4                                 
> 51                      3
> >
> >     
> 5                                 
> 69                      5
> >
> >     
> 6                                 
> 84                      8
> >
> >     
> 7                                 
> 91                      9
> >
> >     
> 8                                 
> 74                      6
> >
> >     
> 9                                 
> 83                      7
> >
> >    
> 10                                
> 96                     10
> >
> > strange eh?
> >
> > ==
> > Brian Hamlin
> > GeoCal
> > OSGeo California Chapter
> > 415-717-4462 cell
> >
> >
> > _______________________________________________
> > postgis-devel mailing list
> > postgis-devel at postgis.refractions.net
> > http://postgis.refractions.net/mailman/listinfo/postgis-devel
> >
> _______________________________________________
> postgis-devel mailing list
> postgis-devel at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-devel
>
>





More information about the postgis-devel mailing list