[postgis-users] ST_Translate

Martin Davis mbdavis at refractions.net
Wed Jul 9 11:02:17 PDT 2008


Thanks for clarifying, Robert - that's exactly what I meant, but I 
couldn't think of the best way to express it in SQL.

Burgholzer,Robert wrote:
> Bob,
> What Marin said was that since you chose to base the offset calculations
> for each shape on the centroid of that particular shape relative to your
> reference shape, all shapes would be moved to center on your reference
> shape. 
>
> If you wish to preserve their positions relative to one another, you
> would have to use the centroid of the group of "process"es being moved
> as the basis for your offset calculations, i.e.:
>
> insert into entity (the_geom, position)
> select
> st_translate (public.process.the_geom,
> st_x (st_centroid(spatial_ref.the_geom)) -
> st_x (st_centroid (old_ref.the_geom)),
> st_y (st_centroid(spatial_ref.the_geom))-
> st_y (st_centroid (old_ref.the_geom))), ('i')
> from  spatial_ref,  process, 
>    (select extent(the_geom) as the_geom from process) as old_ref
> where spatial_ref.position_ = '1' ;
>
> HTH
>
> Robert W. Burgholzer
> Surface Water Modeler
> Office of Water Supply and Planning
> Virginia Department of Environmental Quality
> rwburgholzer at deq.virginia.gov
> 804-698-4405
> Open Source Modeling Tools:
> http://sourceforge.net/projects/npsource/
>
> -----Original Message-----
> From: postgis-users-bounces at postgis.refractions.net
> [mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of Bob
> Pawley
> Sent: Wednesday, July 09, 2008 12:39 PM
> To: PostGIS Users Discussion
> Subject: Re: [postgis-users] ST_Translate
>
> I  thought that the centrioid of each of the six geometries that make up
> the 
> whole would have been translated to its appropriate spot relative to
> where 
> it began.
>
> This is obviously not the case.
>
> Where is my thinking wrong??
>
> Might it have soemthing to do with centroids of individual geometries as
>
> compared to the centroid of the shape as a whole??
>
> Bob
>
> ----- Original Message ----- 
> From: "Martin Davis" <mbdavis at refractions.net>
> To: "PostGIS Users Discussion" <postgis-users at postgis.refractions.net>
> Sent: Wednesday, July 09, 2008 9:07 AM
> Subject: Re: [postgis-users] ST_Translate
>
>
>   
>> Looks to me like you're translating each geometry by a different
>>     
> amount. 
>   
>> Using the SQL below, the centroid of each individual geom will be
>>     
> moved to 
>   
>> be coincident with the centroid of spatial_ref.the_geom.
>>
>> You need to determine a single delta x,y to translate them all by, if
>>     
> you 
>   
>> want them to be in the same position relative to each other.
>>
>> Bob Pawley wrote:
>>     
>>> Hi Regina
>>>
>>> Following is the query I am using.
>>>
>>> The shapefile is also attached if any one wants to try it.
>>>
>>> The shape was converted from a DXF file with the default SRID.
>>>
>>> Bob
>>> insert into entity (the_geom, position)
>>> select
>>> st_translate (public.process.the_geom,
>>> st_x (st_centroid(spatial_ref.the_geom)) -
>>> st_x (st_centroid (public.process.the_geom)),
>>> st_y (st_centroid(spatial_ref.the_geom))-
>>> st_y (st_centroid (public.process.the_geom))), ('i')
>>> from  spatial_ref,  process
>>> where spatial_ref.position_ = '1' ;
>>>
>>>
>>>
>>>
>>>
>>> ----- Original Message ----- From: "Paragon Corporation"
>>>       
> <lr at pcorp.us>
>   
>>> To: "'PostGIS Users Discussion'"
>>>       
> <postgis-users at postgis.refractions.net>
>   
>>> Sent: Wednesday, July 09, 2008 12:11 AM
>>> Subject: RE: [postgis-users] ST_Translate
>>>
>>>
>>>       
>>>> Bob,
>>>>
>>>> Doesn't quite make sense to me why translating before ST_Union would
>>>>         
>
>   
>>>> cause
>>>> distortion if you are translating all the same amount.
>>>>
>>>> What is the SRID of the data you are translating and what does your
>>>> translate query and union query look like?
>>>>
>>>> Thanks,
>>>> Regina
>>>>
>>>> -----Original Message-----
>>>> From: postgis-users-bounces at postgis.refractions.net
>>>> [mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of
>>>>         
> Bob
>   
>>>> Pawley
>>>> Sent: Tuesday, July 08, 2008 5:30 PM
>>>> To: PostGIS Users Discussion
>>>> Subject: [postgis-users] ST_Translate
>>>>
>>>> I've imported a shapefile that requires six rows in the table.
>>>>
>>>> When I translate that shape, of six rows, to another location the
>>>>         
> shape
>   
>>>> becomes distorted.
>>>>
>>>> When I collect the six rows by using ST_Union, then translate the
>>>>         
> single 
>   
>>>> row
>>>> to the new position, there is no distortion.
>>>>
>>>> Is there a method of using ST_Translate, without also using
>>>>         
> ST_Union, 
>   
>>>> and
>>>> still avoid the distortion of the shape??
>>>>
>>>> I need the  geometries of the shape separate to be able to identify
>>>>         
> the
>   
>>>> parts of the shape I need. I seem to lose this informaion when I
>>>>         
> employ
>   
>>>> ST_Union.
>>>>
>>>> Bob
>>>>
>>>> _______________________________________________
>>>> postgis-users mailing list
>>>> postgis-users at postgis.refractions.net
>>>> http://postgis.refractions.net/mailman/listinfo/postgis-users
>>>>
>>>>
>>>> _______________________________________________
>>>> postgis-users mailing list
>>>> postgis-users at postgis.refractions.net
>>>> http://postgis.refractions.net/mailman/listinfo/postgis-users
>>>>         
> ------------------------------------------------------------------------
>   
>>> _______________________________________________
>>> postgis-users mailing list
>>> postgis-users at postgis.refractions.net
>>> http://postgis.refractions.net/mailman/listinfo/postgis-users
>>>
>>>       
>> -- 
>> Martin Davis
>> Senior Technical Architect
>> Refractions Research, Inc.
>> (250) 383-3022
>>
>> _______________________________________________
>> postgis-users mailing list
>> postgis-users at postgis.refractions.net
>> http://postgis.refractions.net/mailman/listinfo/postgis-users 
>>     
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>
>   

-- 
Martin Davis
Senior Technical Architect
Refractions Research, Inc.
(250) 383-3022




More information about the postgis-users mailing list