[R-sig-Geo] MacOS spatial packages installation

jwm302 jwm302 at gmail.com
Thu Jun 5 13:58:08 CEST 2014

Hi Roger

I am really battling to get maptools package to work on on my system (OS X
10.9.3 Mavericks - see session at bottom of message). Everything was working
fine but since I upgraded from R version 3.0 (2013-09-25) -- "Frisbee
Sailing” to R 3.0.2 “Spring Dance”  (because suddenly the extract function
wasn’t working anymore things started to break. 

rgdal seems to be working because I am able to do commands like this with no
error:  surfWater <- readOGR("Surface_water/gns_swb", "gns_swb”) 

I have spent hours sifting through forum posts and the like, but all to no
avail. Either I am missing something obvious, or I am not command line savy
enough to find a solution . This forum (right at the bottom) seems to
suggest that you don’t need to install map tools from source, that the
binaries are available on CRAN. But I see over here
(http://cran.r-project.org/web/packages/maptools/index.html) that OS X
Mavericks binaries are not available. I am confused because I get conflicted
results from my searching on forums. 

I would just like to resolve the issue as soon as possible so that I can get
on with my work.

But as you can see, when I invoke maptools package I get a horrible looking
error and R crashes (the same happens when I perform the same code from the
command line 

> sessionInfo()
R version 3.1.0 (2014-04-10)
Platform: x86_64-apple-darwin13.1.0 (64-bit)

[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] splines   grid      stats     graphics  grDevices utils     datasets 
methods   base     

other attached packages:
 [1] diagram_1.6.2     shape_1.4.1       data.table_1.9.2  tables_0.7.64    
Hmisc_3.14-0      Formula_1.1-1     survival_2.37-7   lattice_0.20-29  
xtable_1.7-1      texreg_1.32      
[11] bootStepAIC_1.2-0 MASS_7.3-31       glm2_1.1.2        plyr_1.8         
RMySQL_0.9-3      DBI_0.2-7         maps_2.3-6        maptools_0.8-29  
gdalUtils_0.2.0   rgdal_0.8-16     
[21] raster_2.2-12     sp_1.0-14        

loaded via a namespace (and not attached):
[1] cluster_1.15.2      codetools_0.2-8     foreach_1.4.1      
foreign_0.8-61      iterators_1.0.6     latticeExtra_0.6-26
RColorBrewer_1.0-5  reshape2_1.2.2      stringr_0.6.2      

> packageInstallLoad <- function(x){
+   for( i in x ){
+     #  require returns TRUE invisibly if it was able to load package
+     if( ! require( i , character.only = TRUE ) ){
+       #  If package was not able to be loaded then re-install
+       #setRepositories(ind = c(1,6))
+       install.packages( i , dependencies = T )
+       #  Load package after installing
+       require( i , character.only = TRUE )
+     }
+   }
+ }
> packageInstallLoad(c("raster", "rgdal", "gdalUtils", "maptools", "sp",
> "maps", "RMySQL", "plyr", "stats", "glm2", "bootStepAIC", "texreg",
> "xtable", "tables", "data.table", "diagram"))
Loading required package: gdalUtils
Loading required package: maps
Loading required package: RMySQL
Loading required package: DBI
Loading required package: plyr
Loading required package: glm2
Loading required package: bootStepAIC
Loading required package: MASS

Attaching package: ‘MASS’

The following objects are masked from ‘package:raster’:

    area, select

Loading required package: texreg
Version:  1.32
Date:     2014-05-01
Author:   Philip Leifeld (University of Konstanz)

Attaching package: ‘texreg’

The following object is masked from ‘package:raster’:


Loading required package: xtable

Attaching package: ‘xtable’

The following object is masked from ‘package:maptools’:


Loading required package: tables
Loading required package: Hmisc
Loading required package: grid
Loading required package: lattice
Loading required package: survival
Loading required package: splines
Loading required package: Formula

Attaching package: ‘Hmisc’

The following objects are masked from ‘package:xtable’:

    label, label<-

The following objects are masked from ‘package:plyr’:

    is.discrete, summarize

The following objects are masked from ‘package:raster’:

    mask, zoom

The following object is masked from ‘package:maptools’:


The following object is masked from ‘package:rgeos’:


The following objects are masked from ‘package:base’:

    format.pval, round.POSIXt, trunc.POSIXt, units

Loading required package: data.table
data.table 1.9.2  For help type: help("data.table")
Loading required package: diagram
Loading required package: shape

Attaching package: ‘diagram’

The following object is masked from ‘package:sp’:


> data(wrld_simpl)
> kenya <- wrld_simpl[wrld_simpl$NAME == "Kenya",]

 *** caught segfault ***
address 0x1150, cause 'memory not mapped'

 1: .Call(bboxCalcR_c, y at polygons)
 2: wrld_simpl[wrld_simpl$NAME == "Kenya", ]
 3: wrld_simpl[wrld_simpl$NAME == "Kenya", ]

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace

Thanks and Regards
Justin Michell

View this message in context: http://r-sig-geo.2731867.n2.nabble.com/MacOS-spatial-packages-installation-tp7583815p7586556.html
Sent from the R-sig-geo mailing list archive at Nabble.com.

More information about the R-sig-Geo mailing list