[postgis-users] Confused about st_snaptogrid and precision.

strk strk at keybit.net
Tue Mar 23 05:10:02 PDT 2010


On Tue, Mar 23, 2010 at 01:05:52PM +0100, strk wrote:
> On Tue, Mar 23, 2010 at 06:57:41AM -0500, Paul Moen wrote:
> 
> > UPDATE the_control SET the_geom=st_snaptogrid(the_geom,.0000001);
> > 
> > After setting the precision, shouldn't I be able to find the point, POINT(1881581.0894989 638200.5564884), at that precision, in the table by using
> > 
> > SELECT * FROM the_control WHERE st_equals(st_geomfromewkt('POINT(1881581.0894989 638200.5564884)'),the_geom);
> 
> You are NOT snapping the return from st_geomfromewkt.
> 
> Try this:
>   SELECT * FROM the_control WHERE st_equals(
>   st_snaptogrid(st_geomfromewkt('POINT(1881581.08949
>   89 638200.5564884)', .0000001)),the_geom);

Also, note that if the geometries you're comparing do not
have the same structure (number of points in the same place)
snapping to the grid may have the unexpected result of making
them different than they were.

This is because snapToGrid doesn't add new vertices, but only
snaps the existing ones.

--strk;

  ()   Free GIS & Flash consultant/developer
  /\   http://strk.keybit.net/services.html



More information about the postgis-users mailing list