[R] *** caught segfault *** error
Juanjo Abellan
j.abellan at imperial.ac.uk
Thu Nov 30 10:37:53 CET 2006
Dear R users,
I use R 2.4.0 on an iMac running Mac OS X 10.4.8, with a 2.16GHz
Intel Core 2 Duo and 2GB 667 MHz DDR2 SDRAM.
> sessionInfo()
R version 2.4.0 (2006-10-03)
i386-apple-darwin8.8.1
locale:
es_ES.UTF-8/es_ES.UTF-8/es_ES.UTF-8/C/es_ES.UTF-8/es_ES.UTF-8
attached base packages:
[1] "methods" "stats" "graphics" "grDevices" "utils"
"datasets" "base"
I get an error below whenever I try to plot a map from a shapefile
imported into R; I've tried packages shapefiles and spdep, and two
different shapefiles, and get the error in all 4 combinations.
The shapefile is imported correctly, and I get the error only when I
try to plot the map. I specifically use commands
> library(spdep)
Loading required package: tripack
Loading required package: maptools
Loading required package: foreign
Loading required package: sp
Loading required package: SparseM
Package SparseM (0.71) loaded. To cite, see citation("SparseM")
Loading required package: boot
> library(maptools)
> district.shp <- read.shape("~/Documents/SAHSU/MD/data/Carthography/
districts_ok.shp")
Shapefile type: Polygon, (5), # of Shapes: 354
> plot(district.shp)
*** caught segfault ***
address 0xc00006d5, cause 'memory not mapped'
Traceback:
1: polygon(theMap$Shapes[[ii]]$verts, col = fg[i], border = ol, ...)
2: plot.Map(district.shp)
3: plot(district.shp)
4: plot(district.shp)
Possible actions:
1: abort (with core dump)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
Selection:
I saw that plot.Map is deprecated, so I converted the shapefile into
a polygon list, and then tried to plot it, but still got the error:
> library(spdep)
Loading required package: tripack
Loading required package: maptools
Loading required package: foreign
Loading required package: sp
Loading required package: SparseM
Package SparseM (0.71) loaded. To cite, see citation("SparseM")
Loading required package: boot
> library(maptools)
> district.shp <- read.shape("~/Documents/SAHSU/MD/data/Carthography/
districts_ok.shp")
Shapefile type: Polygon, (5), # of Shapes: 354
> district.pl <- Map2poly(district.shp, as.character(district.shp$att
$DISTRICT_2))
> plot(district.pl)
*** caught segfault ***
address 0xc0000165, cause 'memory not mapped'
Traceback:
1: polygon(coords[pFrom[i]:pTo[i], ], border = border, xpd = xpd,
density = density, angle = angle)
2: polygonholes(x[[j]], border = border, xpd = xpd, density = density
[j], angle = angle[j], pbg = pbg, forcefill = forcefill)
3: plot.polylist(district.pl)
4: plot(district.pl)
5: plot(district.pl)
Possible actions:
1: abort (with core dump)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
Selection:
I also get the same error when I use library shapefiles to import the
shp file and then try to plot the polygons myself; these are the
commands I run:
> library(shapefiles)
> districts.shp <- read.shapefile("~/Documents/SAHSU/MD/data/
carthography/districts_ok")
Attaching package: 'foreign'
The following object(s) are masked from package:shapefiles :
read.dbf
The following object(s) are masked from package:shapefiles :
write.dbf
> ndistricts <- length(districts.shp$shp$shp)
> keys <- districts.shp$dbf$dbf$DISTRICT_2
> vertices <- list()
> for(i in 1:ndistricts){
+ vertices[[i]] <- districts.shp$shp$shp[[i]]$points
+ }
>
> districts.map <- list(codigo=keys, vertices=vertices)#,
nombre=wardnames)
>
> xymin <- apply(t(sapply(districts.map$vertices, apply, 2, min)),
2, min)
> xymax <- apply(t(sapply(districts.map$vertices, apply, 2, max)),
2, max)
> corners <- expand.grid(xymin, xymax)
>
> # Plotting the corners and then adding polygons one by one.
> par(pty="s")
> plot(rbind(xymin, xymax), type="n")
> for (i in 1:ndistricts){
+ polygon(x=districts.map$vertices[[i]][,1], y=districts.map
$vertices[[i]][,2])
+ }
*** caught segfault ***
address 0xc00009d8, cause 'memory not mapped'
Traceback:
1: polygon(x = districts.map$vertices[[i]][, 1], y = districts.map
$vertices[[i]][, 2])
Possible actions:
1: abort (with core dump)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
Selection:
The same commands work fine in my laptop (Intel Pentium 4 CPU 2.00
GHz, with 512 MB RAM), where I use R v2.2.1 on Windows XP Home
Edition v2002.
Any ideas of what may cause the error?
Many thanks,
Juanjo Abellan
Research Associate in Statistics
Department of Epidemiology and Public Health
Imperial College London
More information about the R-help
mailing list