Dear all, I forgot to mention that Roger Bivand, who developed package maptools, wrote a special function for me to determine which polygon caused the error. The error happens on the 256th polygon, and he suspects this is a signal that the loop index is running in a variable of the wrong size (in an unsigned byte 0-255) ? I guess the question is could I run a debugger with R.app to actually trap the error.
Many thanks. Juanjo -----Original Message----- From: Abellan Andres, Juanjo Sent: 06 December 2006 10:39 To: '[email protected]' Cc: 'Roger Bivand'; Turro, Ernest Subject: *** caught segfault *** error Dear R for Mac 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. 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) > 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" other attached packages: spdep boot SparseM maptools sp foreign tripack "0.3-32" "1.2-26" "0.71" "0.6-3" "0.9-4" "0.8-17" "1.2-10" > district.shp <- read.shape("~/Documents/SAHSU/MD/data/Carthography/districts_ok.shp") Shapefile type: Polygon, (5), # of Shapes: 354 > 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: In all above cases, I can generate a postscript file though. I.e. the sequence of commands >districts.shp <- read.shape("~/Documents/SAHSU/MD/data/Carthography/districts_ok.shp") Shapefile type: Polygon, (5), # of Shapes: 354 > postscript("~/Documents/SAHSU/MD/data/Carthography/districts_ok.eps") > plot(districts.shp) Warning message: 'plot.Map' is deprecated. Use 'plot.Spatial' instead. See help("Deprecated") and help("maptools-deprecated"). > dev.off() null device 1 works fine, and the postscript file with the map is created. The same commands work fine using R terminal instead of R.app. So the error only happens in R.app when generating the map to be seen on teh screen. They also 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. A colleague of mine's reproduced the error using R.app on the following machine: System Version: Mac OS X 10.4.8 (8N1051) Kernel Version: Darwin 8.8.2 Hardware Overview: Machine Name: Mac Machine Model: MacBookPro2,2 Processor Name: Intel Core 2 Duo Processor Speed: 2.33 GHz Number Of Processors: 1 Total Number Of Cores: 2 L2 Cache (per processor): 4 MB Memory: 2 GB Bus Speed: 667 MHz > sessionInfo() R version 2.4.0 (2006-10-03) i386-apple-darwin8.8.1 locale: en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8 attached base packages: [1] "methods" "stats" "graphics" "grDevices" "utils" [6] "datasets" "base" other attached packages: spdep boot SparseM maptools sp foreign tripack "0.3-32" "1.2-26" "0.71" "0.6-3" "0.9-4" "0.8-17" "1.2-10" The offending shapefile was generated with ArcGIS 9.0 running on Windows XP. It can be can be found in www.uv.es/~abellan/districts_ok.zip. 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 _______________________________________________ R-SIG-Mac mailing list [email protected] https://stat.ethz.ch/mailman/listinfo/r-sig-mac
