I have two polygons poly1 and poly0, I need the difference area of them. Below is my trial:

poly0 = Import["t0.txt", "Data"]
poly1 = Import["t1.txt", "Data"]

Graphics[{Red, Polygon@poly0 , Green, Polygon@poly1}]

enter image description here


enter image description here

Obviously, the RegionDifference cannot work normally.

enter image description here




  • $\begingroup$ Are you sure you don't have some old definitions? Try clearing all global variables or quitting the kernel. I have no problem with getting the RegionMeasure of RegionMeasure as in your post, as well as in Mauricio's answer. $\endgroup$ – corey979 Nov 14 '16 at 9:24
  • $\begingroup$ @corey979 Yes, In addtion, I guess your Mathematica version is V11.0.1, rather than 10.4 or 11.0.0 $\endgroup$ – user123 Nov 14 '16 at 9:45
  • $\begingroup$ No, I'm on 10.4.1 for Linux x86 (64-bit). $\endgroup$ – corey979 Nov 14 '16 at 9:47

Try using DiscretizeRegion first

r1 = DiscretizeRegion@Polygon@poly0;
r2 = DiscretizeRegion@Polygon@poly1;
rd = RegionDifference[r2, r1]

enter image description here

  • $\begingroup$ I got this i.stack.imgur.com/SHfE5.png in Mma 10.4 $\endgroup$ – user123 Nov 14 '16 at 7:44
  • $\begingroup$ hmmm .... weird .... I am using Mathematica 11. Perhaps there were some problems with RegionDifference in 10.4. Sorry, no idea in that case $\endgroup$ – Mauricio Fernández Nov 14 '16 at 7:51
  • $\begingroup$ That's all right:) Mma 11 also fails to return the result you give. $\endgroup$ – user123 Nov 14 '16 at 7:55
  • $\begingroup$ What?? In Mma 11 it does not work for you? Did you just copy paste the code I posted? It should work with Mma 11. $\endgroup$ – Mauricio Fernández Nov 14 '16 at 7:59
  • $\begingroup$ Yes, here is the snapshot i.stack.imgur.com/GFm4r.png $\endgroup$ – user123 Nov 14 '16 at 8:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.