Skip to main content
Became Hot Network Question
Tweeted twitter.com/StackGIS/status/1335645230192791552
added 511 characters in body
Source Link
Pateheo
  • 265
  • 2
  • 7

There are two multi-polygons a and A where a is supposed to be contained inside A. Using shapely, the following difference operator

b = a.difference(A)
print(b)

gives

POLYGON EMPTY

However testing A.contains(a) returns False; a.touches(A) also gives False.

How could this be possible with Shapely?

The wkt descriptions for A and a are hosted in the following Gist link (due to characters limit) https://gist.github.com/vodp/169b12f507a9730c0dd2ac86ca2589db

Edits

So what I am trying to test is assessing the equivalence between

a.difference(A) -> False

and

A.contains(a) -> True

But A.contains(a) returns False instead. If I were buffering a bit, for example

A.contains(a.buffer(-1))

then I get True. Notice that both

aa = a.buffer(-1)
aa.difference(A) -> EMPTY

and

a.difference(A) -> EMPTY

Does that mean for contains to work, none of the point of a lying in the boundary of A ?

Any chance this is because of rounding errors? I try to get the minimal buffering value and the smallest one I could get before .contains() return False is that:

A.contains(a.buffer(-0.000000001)) # 1e-9

There are two multi-polygons a and A where a is supposed to be contained inside A. Using shapely, the following difference operator

b = a.difference(A)
print(b)

gives

POLYGON EMPTY

However testing A.contains(a) returns False; a.touches(A) also gives False.

How could this be possible with Shapely?

The wkt descriptions for A and a are hosted in the following Gist link (due to characters limit) https://gist.github.com/vodp/169b12f507a9730c0dd2ac86ca2589db

There are two multi-polygons a and A where a is supposed to be contained inside A. Using shapely, the following difference operator

b = a.difference(A)
print(b)

gives

POLYGON EMPTY

However testing A.contains(a) returns False; a.touches(A) also gives False.

How could this be possible with Shapely?

The wkt descriptions for A and a are hosted in the following Gist link (due to characters limit) https://gist.github.com/vodp/169b12f507a9730c0dd2ac86ca2589db

Edits

So what I am trying to test is assessing the equivalence between

a.difference(A) -> False

and

A.contains(a) -> True

But A.contains(a) returns False instead. If I were buffering a bit, for example

A.contains(a.buffer(-1))

then I get True. Notice that both

aa = a.buffer(-1)
aa.difference(A) -> EMPTY

and

a.difference(A) -> EMPTY

Does that mean for contains to work, none of the point of a lying in the boundary of A ?

Any chance this is because of rounding errors? I try to get the minimal buffering value and the smallest one I could get before .contains() return False is that:

A.contains(a.buffer(-0.000000001)) # 1e-9
edited tags
Link
gene
  • 55.4k
  • 3
  • 113
  • 191
Source Link
Pateheo
  • 265
  • 2
  • 7

Multipolygon supposed to be contained by another but returned False with Shapely

There are two multi-polygons a and A where a is supposed to be contained inside A. Using shapely, the following difference operator

b = a.difference(A)
print(b)

gives

POLYGON EMPTY

However testing A.contains(a) returns False; a.touches(A) also gives False.

How could this be possible with Shapely?

The wkt descriptions for A and a are hosted in the following Gist link (due to characters limit) https://gist.github.com/vodp/169b12f507a9730c0dd2ac86ca2589db