
R version 4.3.0 (2023-04-21) -- "Already Tomorrow"
Copyright (C) 2023 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> suppressPackageStartupMessages(library(rgeos))
> # g1 is invalid
> g1 <- readWKT('POLYGON((0 0, 10 10, 0 10, 10 0, 0 0))')
> g2 <- readWKT('POLYGON((2 2, 8 2, 8 8, 2 8, 2 2))')
> 
> # binary operators
> try(g3 <- gUnion(g1, g2))
g1 is invalid
Error in RGEOSBinTopoFunc(spgeom1, spgeom2, byid, id, drop_lower_td, unaryUnion_if_byid_false,  : 
  TopologyException: side location conflict at 5 5. This can occur if the input geometry is invalid.
In addition: Warning messages:
1: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
  Self-intersection at or near point 5 5
2: In gUnion(g1, g2) :
  Invalid objects found; consider using set_RGEOS_CheckValidity(2L)
3: GEOS support is provided by the sf and terra packages among others 
> try(g3 <- gDifference(g1, g2))
g1 is invalid
Error in RGEOSBinTopoFunc(spgeom1, spgeom2, byid, id, drop_lower_td, unaryUnion_if_byid_false,  : 
  TopologyException: side location conflict at 5 5. This can occur if the input geometry is invalid.
In addition: Warning messages:
1: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
  Self-intersection at or near point 5 5
2: In gDifference(g1, g2) :
  Invalid objects found; consider using set_RGEOS_CheckValidity(2L)
3: GEOS support is provided by the sf and terra packages among others 
> try(g3 <- gIntersection(g1, g2))
g1 is invalid
Error in RGEOSBinTopoFunc(spgeom1, spgeom2, byid, id, drop_lower_td, unaryUnion_if_byid_false,  : 
  TopologyException: side location conflict at 5 5. This can occur if the input geometry is invalid.
In addition: Warning messages:
1: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
  Self-intersection at or near point 5 5
2: In gIntersection(g1, g2) :
  Invalid objects found; consider using set_RGEOS_CheckValidity(2L)
3: GEOS support is provided by the sf and terra packages among others 
> try(g3 <- gSymdifference(g1, g2))
g1 is invalid
Error in RGEOSBinTopoFunc(spgeom1, spgeom2, byid, id, drop_lower_td, unaryUnion_if_byid_false,  : 
  TopologyException: side location conflict at 5 5. This can occur if the input geometry is invalid.
In addition: Warning messages:
1: In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
  Self-intersection at or near point 5 5
2: In gSymdifference(g1, g2) :
  Invalid objects found; consider using set_RGEOS_CheckValidity(2L)
3: GEOS support is provided by the sf and terra packages among others 
> 
> # unary operators
> try(g3 <- gSimplify(g1, tol=0.1))
> try(g3 <- gPolygonize(list(as(g1, "SpatialLines"))))
> try(g3 <- gEnvelope(g1))
> try(g3 <- gConvexHull(g1))
> try(g3 <- gBoundary(g1))
> try(g3 <- gCentroid(g1))
> try(g3 <- gPointOnSurface(g1))
> 
> # binary predicates
> try(res <- gContains(g1, g2))
> try(res <- gIntersects(g1, g2))
> try(res <- gContainsProperly(g1, g2))
> try(res <- gCovers(g1, g2))
> try(res <- gCoveredBy(g1, g2))
> try(res <- gDisjoint(g1, g2))
> try(res <- gTouches(g1, g2))
> try(res <- gCrosses(g1, g2))
> try(res <- gWithin(g1, g2))
> try(res <- gOverlaps(g1, g2))
> try(res <- gEquals(g1, g2))
> try(res <- gEqualsExact(g1, g2))
> try(res <- gRelate(g1, g2))
> 
> # unary predicates
> try(res <- gIsEmpty(g1))
> try(res <- gIsSimple(g1))
> try(res <- gIsRing(g1))
> try(res <- gIsValid(g1))
Warning message:
In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
  Self-intersection at or near point 5 5
> try(res <- gIsValid(g1, reason = TRUE))
> 
> 
> proc.time()
   user  system elapsed 
  0.313   0.038   0.343 
