0

I've been having an issue in R that causes the program to crash. I've finally been able to narrow the problem down to the following.

I find that the following works:

library(rgeos)
x = readWKT("POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))")
gIsValid(x)
[1] TRUE

However, the following results in a crash:

library(rgdal)
x = rgeos::readWKT("POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))")
rgeos::gIsValid(x)

In an R package I'm working on, rgdal is specified under "Depends", and rgeos under "Imports" in the Description file. So I have code that has been behaving more like the second (crashing) scenario.

Here is some info that might be useful:

> library(rgeos)
rgeos version: 0.3-23, (SVN revision 546)
 GEOS runtime version: 3.6.1-CAPI-1.10.1 r0 
 Linking to sp version: 1.2-4 
 Polygon checking: TRUE 

> library(rgdal)
Loading required package: sp
rgdal: version: 1.2-7, (SVN revision 660)
 Geospatial Data Abstraction Library extensions to R successfully loaded
 Loaded GDAL runtime: GDAL 1.11.5, released 2016/07/01
 Path to GDAL shared files: /usr/local/Cellar/gdal/1.11.5_2/share/gdal
 Loaded PROJ.4 runtime: Rel. 4.9.3, 15 August 2016, [PJ_VERSION: 493]
 Path to PROJ.4 shared files: (autodetected)
 Linking to sp version: 1.2-4 
> sessionInfo()
R version 3.4.0 (2017-04-21)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Sierra 10.12.5

Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] rgdal_1.2-7  sp_1.2-4     rgeos_0.3-23

loaded via a namespace (and not attached):
[1] compiler_3.4.0  grid_3.4.0      lattice_0.20-35

Any ideas on how this can be avoided? Is this a bug in geos? gdal?

Pascal
  • 1,590
  • 2
  • 16
  • 35
  • Are you feeding it a small set like above or is it a whole host of points to run? – sconfluentus May 24 '17 at 01:01
  • I found the same behavior when providing a polygon with many more vertices, if that's what you mean. – Pascal May 24 '17 at 01:16
  • A workaround of course is to just load the rgeos package first. – Pascal May 24 '17 at 01:17
  • Yes, I was going to suggest loading `rgeos` first. It really should not just crash, but if it takes up a lot of memory and R feels the need to create multiple copies of a mondo data set as it does its work, I can see there might be a problem, but I have never had this happen myself and I am using Darwin on the same version of Sierra with a lot of RAM and 8 cores. – sconfluentus May 24 '17 at 01:30
  • Yeah, it is crashing with tiny datasets like the one shown in the example, so it doesn't seem to be that the memory is getting overloaded. – Pascal May 24 '17 at 01:38
  • That is peculiar. Have you tried updating both packages and restarting the computer? I tried pretty hard to crash it with your basic code and it not only did not crash the computer did not even blink processing the commands... – sconfluentus May 24 '17 at 01:40
  • Hmm ok, rebooting didn't solve it, but reinstalling the packages did. I appreciate your help! – Pascal May 24 '17 at 02:59
  • sweet....happy mapping! – sconfluentus May 24 '17 at 03:00

1 Answers1

0

In the end, rebooting the computer, reinstalling the rgeos and rgdal packages led to this code no longer crashing R.

Pascal
  • 1,590
  • 2
  • 16
  • 35