[postgis-users] st_difference on more than two geometries

Markus Innerebner markus.innerebner at inf.unibz.it
Tue Sep 11 08:43:36 PDT 2012


Hi Sandro,

I guess you been something like this:

select
st_difference(
   st_buffer(st_pointfromtext('POINT(680386.8879388 5152170.83093339)',82344),9000.0),
   st_union(
     st_buffer(st_pointfromtext('POINT(688402.843016069 5157054.21005474)',82344),3000.0),
     st_union(
       st_buffer(st_pointfromtext('POINT(680910.532411225 5142908.46168964)',82344),5000.0),
       st_buffer(st_pointfromtext('POINT(674802.141078014 5161560.18713918)',82344),5860.0)
     )
   )
)


cheers Markus

-- 
Ph D. Student Markus Innerebner

DIS Research Group - Faculty of Computer Science
Free University Bozen-Bolzano

Dominikanerplatz 3 - Room 211
I - 39100 Bozen
Phone:  +39-0471-016143
Mobile: +39-333-9392929


gpg --fingerprint
-------------------------------------
pub   1024D/588F6308 2007-01-09
      Key fingerprint = 6948 947E CBD2 89FD E773  E863 914F EB1B 588F 6308
sub   2048g/BF4877D0 2007-01-09

On Sep 11, 2012, at 5:26 PM, Sandro Santilli wrote:

> On Tue, Sep 11, 2012 at 04:29:07PM +0200, Markus Innerebner wrote:
>> Hello,
>> 
>> I have a question regarding the st_difference operation:
>> 
>> I want to identify the non overlapping area of a given polygon, that might intersect with arbitrary other polygons.
>> I realized, that st_difference operation works only with two parameters. The API says not to use it with geometry collections.
>> 
>> In order to realize this, I needed to do combine st_intersection with st_difference in recursive manner as shown below with the following output:
>> 
>> 
>> st_intersection(
>>  st_intersection(
>>    st_difference(
>>      st_buffer(st_pointfromtext('POINT(680386.8879388 5152170.83093339),82344),9000.0),
>>      st_buffer(st_pointfromtext('POINT(688402.843016069 5157054.21005474),82344),3000.0)
>>    ),
>>    st_difference(
>>     st_buffer(st_pointfromtext('POINT(680386.8879388 5152170.83093339),82344),9000.0),
>>     st_buffer(st_pointfromtext('POINT(674802.141078014 5161560.18713918),82344),5860.0)
>>    )
>>   ),st_difference(
>>     st_buffer(st_pointfromtext('POINT(680386.8879388 5152170.83093339),82344),9000.0),
>>     st_buffer(st_pointfromtext('POINT(680910.532411225 5142908.46168964),82344),5000.0)
>>   )
>>  )
>> )
>> )
>> 
>> my question now is: Is there a simpler way?
> 
> You may union the parts to subtract and then call difference only once.
> Leaving out the parts that do not intersect with the bounding box of
> the first geometry is advisable.
> 
> --strk; 
> 
> http://www.cartodb.com - Map, analyze and build applications with your data
> 
>                                       ~~ http://strk.keybit.net 
> 
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users




More information about the postgis-users mailing list