I want to clip two SpatialPolygons on R without success, I followed the article in the disscution How to perform a true GIS clip of polygons layer using a polygon layer in R?
Polygone 01 :
> polygone1
class : SpatialPolygons
features : 1
extent : -8.673868, 11.98891, 19.43771, 37.09514 (xmin, xmax, ymin, ymax)
coord. ref. : +init=epsg:4326 +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
Polygone 02 :
> Polygone2
class : SpatialPolygons
features : 4
extent : 0.665381, 12.35598, 30.72105, 37.50386 (xmin, xmax, ymin, ymax)
coord. ref. : +init=epsg:4326 +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
Code :
clip2 <- gIntersection(Polygone1, Polygone2, byid=TRUE)
Erreur :
Error in RGEOSBinTopoFunc(spgeom1, spgeom2, byid, id, drop_not_poly, "rgeos_intersection") :
TopologyException: Input geom 0 is invalid: Self-intersection at or near point 8.1451386683704339 37.192197131616837 at 8.1451386683704339 37.192197131616837
Does anyone can help me?