[postgis-users] Snapped polygon

Nicolas Ribot nicolas.ribot at gmail.com
Tue Jul 20 08:15:40 PDT 2010


> Hi.
> I'm, having a problem with some geometries.
> I have buildings and blocks represented by polygons, and I have to check
> if buildings are contained in blocks.
>
> The problem is that buildings that are snapped to blocks sides, aren't
> considered inside the block.
>
> These are the validations that I've used so far.
>
> ST_Covers(block, building) => false
> ST_Contains(block, building) => false
> ST_Coveredby(building, block) => false
> ST_Within(building, block) => false
>
>
> The following validations are the ones that confuses me.
>
> ST_Covers(ST_intersection(block, building), building) => true
> ST_Intersection(block, building) = building => true
> ST_isEmpty(ST_Difference(building, block)) => true
>
> For what I've read, here
> http://lin-ear-th-inking.blogspot.com/2007/06/subtleties-of-ogc-covers-spatial.html
> "Geometry A covers Geometry B if no points of B lie in the exterior of
> A"
> Covers should return true.
>
> The environment is:
> SELECT version(); => "PostgreSQL 8.4.4 on x86_64-pc-linux-gnu, compiled
> by GCC gcc-4.3.real (Debian 4.3.2-1.1) 4.3.2, 64-bit"
>
> SELECT postgis_version(); => "1.5 USE_GEOS=1 USE_PROJ=1 USE_STATS=1"
>
> I've attached two geometries that you can use to check if I'm doing
> something wrong.
>
> Thanks for your time.
> --

Hi,

For this kind of relationship, st_relate is very powerful: a good
explanation is given here:
http://2007.foss4g.org/presentations/view.php?abstract_id=117
along with a concrete example that, if I recall correctly, is pretty
much the same as yours.


Nicolas



More information about the postgis-users mailing list