views:

24

answers:

2

Is there a way to subtract a geometry from another? A kind of reverse STUnion..

The problem I am having is that I need to ensure a shape fits within another (without changing the larger shape). I thought I could use the STIntersection to get the shape thats "in". However, STIntersection is not accurate and produces a shape that can (and does) not equate to the true intersection.

You can easily see this if you then take the STDifference of the original shape.

So , what I would like to do is given two shapes I want to subtract one from the other - e.g. Take the STIntersection and then subtract the STDifference.

Any ideas?

Edit: For now, I have created my intersection from a STBuffer(-1) version of the bigger shape, this should account the mathematical variation of STIntersection with a slight reduction in accuracy. However, I would still love to know if you can subtract a geometry from another..

A: 

Did you try STWithin?

Cahit
I am trying to ensure the STWithin captures the shape that isnt quite in.. so I create a new shape of the intersection (which is supposed to be within, right?) but it isnt. There's this little bit left over and therefore its failing the STWithin. So I wanted a way to subtract a geometry from another (taking away the bit that was left over from the failed intersection).
Barry King
A: 

Just use .STDifference(). No need to intersect first, then subtract the intersection. Just subtract directly.

Peter