You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When points lie close to +/-180° of longitude, it may happen that a polygon created by circles() has to cross the antimeridian. Depending on how "dissolve" is set, the command then either fails with
Error in rgeos::gUnaryUnion(ci@polygons) :
TopologyException: Input geom 0 is invalid: Self-intersection at or near point X Y
or the resulting polygons are broken. I hope the following example illustrates the issue:
library(dismo)
library(maptools)
data("wrld_simpl")
# example locations
locations <- SpatialPoints(coords=cbind(c(0,0,0,0, 175, -160), c(10, 30, 50, 70,0,-10)),
proj4string = CRS("+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0"))
plot(wrld_simpl)
points(locations, pch=19, col="blue")
# this gives an error because of self-intersection
buffer <- circles(p = locations, d = 1500000, lonlat=TRUE)
# this exercutes:
buffer <- circles(p = locations, d = 1500000, lonlat=TRUE, dissolve=FALSE)
# but looks weird:
plot(wrld_simpl)
plot(buffer, add=TRUE, col="red")
points(locations, pch=19, col="blue")
# ... and leads to problems later on
gUnaryUnion(buffer@polygons)
I've spend numerous hours now trying to find an alternative, somehow work around the issue, or manually clean up the broken output. But it's always one step forward and two steps back, so I hope this can somehow be fixed at the source …
The text was updated successfully, but these errors were encountered:
Just for the record: A viable work-around using st_wrap_dateline() from the sf package has been provided at stackoverflow, so personally I'm good for now.
When points lie close to +/-180° of longitude, it may happen that a polygon created by circles() has to cross the antimeridian. Depending on how "dissolve" is set, the command then either fails with
or the resulting polygons are broken. I hope the following example illustrates the issue:
I've spend numerous hours now trying to find an alternative, somehow work around the issue, or manually clean up the broken output. But it's always one step forward and two steps back, so I hope this can somehow be fixed at the source …
The text was updated successfully, but these errors were encountered: