I can't use the gDistance function of rgeos without a R crash even when I used the example script:
pt1 = readWKT("POINT(0.5 0.5)")
pt2 = readWKT("POINT(2 2)")
gDistance(pt1,pt2,T)
*** caught segfault ***
address (nil), cause 'unknown'
Traceback:
1: .Call("rgeos_distance", .RGEOS_HANDLE, spgeom1, spgeom2,byid, PACKAGE = "rgeos")
2: RGEOSDistanceFunc(spgeom1, spgeom2, byid, "rgeos_distance")
3: gDistance(pt1, pt2, T)
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
rgeos version: 0.3-19, (SVN revision 524) GEOS runtime version: 3.5.0-CAPI-1.9.0 r0 Linking to sp version: 1.2-3
Anyone have an idea ?
Edit: sessionInfo() gives
R version 3.3.1 (2016-06-21)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: Scientific Linux release 6.6 (Carbon)
I just tested gBuffer and it does not work as well
pt1 = readWKT("POINT(0.5 0.5)")
gBuffer(pt1)
*** caught segfault ***
address (nil), cause 'unknown'
Traceback:
1: .Call("rgeos_buffer", .RGEOS_HANDLE, spgeom, byid, id, width, quadsegs, capStyle, joinStyle, mitreLimit, PACKAGE = "rgeos")
2: gBuffer(pt1)
Edit2 : I did some additional tests : the problem occurs whatever the rgeos version I use. When I use geos version <3.4.2 gDistance produces this error:
GeometryComponentFilter.cpp:35: virtual void geos::geom::GeometryComponentFilter::filter_ro(const geos::geom::Geometry*): Assertion `0' failed. Abandon
while gBuffer(pt1) works ! As rcs wrote, this error has been reported (and seems unsolved) stat.ethz.ch/pipermail/r-sig-geo/2015-February/022311.html
For version >3.5.0 neither gDistance nor gBuffer work but no error mess is outputted (only the segfault, see above)
Edit 3: I tried to go through the C-code of rgeos and I noticed that the segfault appears in this function:
GEOSGeom rgeos_xy2Pt(SEXP env, double x, double y)
where
s = GEOSCoordSeq_create_r(GEOShandle, (unsigned int) 1, (unsigned int) 2);
return an empty pointer that causes the segfault in
GEOSCoordSeq_setX_r(GEOShandle, s, 0, x)
sessionInfo()
to your question; it works also an my system (Ubuntu 16.04/R 3.3.1/rgeos version: 0.3-19, (SVN revision 524)/GEOS runtime version: 3.5.0-CAPI-1.9.0 r4084)