dwww Home | Show directory contents | Find package

> library(s2)
> s2_set_snaplevel(30) # for windows i386
[1] -1
> u = s2_union(
+    "POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))",
+    "POLYGON ((5 5, 15 5, 15 15, 5 15, 5 5))"
+ )
> s2_area(u, radius = 1)
[1] 0.05284581
> s2_area("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))", radius = 1) +
+ s2_area("POLYGON ((5 5, 15 5, 15 15, 5 15, 5 5))", radius = 1) -
+ s2_area("POLYGON ((5 5, 10 5, 10 15, 5 10, 5 5))", radius = 1)
[1] 0.04910511
> s2_area("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))", radius = 1)
[1] 0.03038216
> s2_area("POLYGON ((5 5, 15 5, 15 15, 5 15, 5 5))", radius = 1)
[1] 0.03002974
> s2_area("POLYGON ((5 5, 10 5, 10 15, 5 10, 5 5))", radius = 1)
[1] 0.01130679
> 
> df = s2_difference(
+       "POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))",
+       "POLYGON ((5 5, 15 5, 15 15, 5 15, 5 5))"
+       )
> s2_area(df, radius = 1) -
+   (s2_area("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))", radius = 1) -
+     s2_area("POLYGON ((5 5, 10 5, 10 15, 5 10, 5 5))", radius = 1))
[1] 0.003740703
> 

Generated by dwww version 1.15 on Sun Jun 23 22:03:17 CEST 2024.