Subtracting a SQL Server geometry from another

会有一股神秘感。 提交于 2020-01-06 03:11:26

问题


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..


回答1:


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




回答2:


Did you try STWithin?



来源:https://stackoverflow.com/questions/3415242/subtracting-a-sql-server-geometry-from-another

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!