Problem with st_translate

View: New views
2 Messages — Rating Filter:   Alert me  

Problem with st_translate

by Bob Pawley :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Hi
 
I have a table holding a number of rows of points which I want to translate from covering Box 1 to covering Box 2.
 
When I use the following all of the points are translated to the same central position (200 points stacked upon each other)
 
 insert into fluids (one)
 select st_translate(graphics.point_grid.the_geom,
 st_x(st_centroid(library.dgm_process.the_geom)) -
 st_x(st_centroid(graphics.point_grid.the_geom)),
 st_y(st_centroid(library.dgm_process.the_geom)) -
 st_y(st_centroid(graphics.point_grid.the_geom)))
 from  library.dgm_process, graphics.point_grid
 where library.dgm_process.process_number = '1'
 and graphics.point_grid.number = '1' ;
I've tried variations of the above without success.

When the same points are collected in a st_union operation occupying a single row the preceding works well.
 
I need these points in separate entities in order to select particular points, using the following -
 
insert into fluids (one)
 select st_translate(graphics.point_grid.the_geom,
 st_x(st_centroid(library.dgm_process.the_geom)) -
 st_x(st_centroid(graphics.point_grid.the_geom)),
 st_y(st_centroid(library.dgm_process.the_geom)) -
 st_y(st_centroid(graphics.point_grid.the_geom)))
 from  library.dgm_process, graphics.point_grid
 where library.dgm_process.process_number = '1'
 and graphics.point_grid.number = '1'
 and st_within( graphics.point_grid.the_geom, st_box2d(library.dgm_process.the_geom)) = 't'
 and graphics.point_grid.the_geom <<| st_centroid(library.dgm_process.the_geom) ;
 
Is there some method of which I am unaware, for translating single points to a new location with the same relationship one to another??
 
Bob
 

_______________________________________________
postgis-users mailing list
postgis-users@...
http://postgis.refractions.net/mailman/listinfo/postgis-users

Re: Problem with st_translate

by Maxime van Noppen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Bob Pawley wrote:

> Hi
>  
> I have a table holding a number of rows of points which I want to
> translate from covering Box 1 to covering Box 2.
>  
> When I use the following all of the points are translated to the same
> central position (200 points stacked upon each other)
>  
>  insert into fluids (one)
>  select st_translate(graphics.point_grid.the_geom,
>  st_x(st_centroid(library.dgm_process.the_geom)) -
>  st_x(st_centroid(graphics.point_grid.the_geom)),
>  st_y(st_centroid(library.dgm_process.the_geom)) -
>  st_y(st_centroid(graphics.point_grid.the_geom)))
>  from  library.dgm_process, graphics.point_grid
>  where library.dgm_process.process_number = '1'
>  and graphics.point_grid.number = '1' ;
> I've tried variations of the above without success.
>
> When the same points are collected in a st_union operation occupying a
> single row the preceding works well.

Hi,

From what I understand the behaviour is normal. You ask to translate all
the points to the st_centroid of the destination geometry. The
ST_Translate arguments that you provide are those of the vector between
the points and the centroid of the destination geometry, which therefore
translates all the points to this place.

To achieve what you want you'll have to compute the vector from the
centroid of the first geometry to the second, and apply this to your
points. The arguments to the st_translate you should be using are :

vec_x = st_x(st_centroid(geom_2)) - st_x(st_centroid(geom_1))
vec_y = st_y(st_centroid(geom_2)) - st_y(st_centroid(geom_1))

This also explains why it worked with all the points packed into a
single geometry.

--
Maxime
_______________________________________________
postgis-users mailing list
postgis-users@...
http://postgis.refractions.net/mailman/listinfo/postgis-users