[R] *** caught segfault *** error

Juanjo Abellan j.abellan at imperial.ac.uk
Fri Dec 1 14:23:30 CET 2006


Dear all,

The 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.

Re running sessionInfo() before the error occurres as suggested by  
Prof. Ripley:

 > 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
 > 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:



Re trying maptools "example(read.shape)" as suggested by Dr Bivand:

 > example(read.shape)

rd.shp> x <- read.shape(system.file("shapes/sids.shp", package =  
"maptools")[1])
Shapefile type: Polygon, (5), # of Shapes: 100

rd.shp> length(x$Shapes)
[1] 100

rd.shp> unlist(lapply(x$att.data, class))
      AREA PERIMETER     CNTY_   CNTY_ID      NAME      FIPS     
FIPSNO  CRESS_ID     BIR74     SID74
"numeric" "numeric" "numeric" "numeric"  "factor"  "factor" "numeric"  
"numeric" "numeric" "numeric"
   NWBIR74     BIR79     SID79   NWBIR79
"numeric" "numeric" "numeric" "numeric"

rd.shp> str(getinfo.shape(system.file("shapes/fylk-val.shp",
     package = "maptools")[1]))
List of 5
$ : chr "/Library/Frameworks/R.framework/Versions/2.4/Resources/ 
library/maptools/shapes/fylk-val.shp"
$ : int 3
$ : int 97
$ : num [1:4]   -4868 6456207       0       0
$ : num [1:4] 1084722 7841997       0       0
- attr(*, "class")= chr "shapehead"
 > plot(x)
Warning message:
'plot.Map' is deprecated.
Use 'plot.Spatial' instead.
See help("Deprecated") and help("maptools-deprecated").

The maps is plotted.

Sorry, I didn't understand the issue about the locale and the C  
locale that Prof Ripley mentioned. Where could I learn about that?

Thanks,

Juanjo



El 30/11/2006, a las 11:41, Prof Brian Ripley escribió:

> On Thu, 30 Nov 2006, Roger Bivand wrote:
>
>> On Thu, 30 Nov 2006, Juanjo Abellan wrote:
>>
>>> 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.
>>>
>>
>> Please make a copy of the offending shapefile available either on a
>> website or attach it to me off-list. It would be useful to know  
>> its origin
>> (which software wrote it) and whether the copy on the iMac is  
>> identical to
>> the copy on the Windows PC (perhaps attach both?). Can other  
>> shapefiles be
>> read on the iMac?
>>
>> (This may be an R-sig-Mac issue as well as an R-sig-geo issue, so  
>> if other
>> iMac users could check whether example(read.shape) in the maptools  
>> package
>> works for them on similar hardware, I'd be grateful)
>
> And also please run sessionInfo() *after* attaching the packages,  
> since all the version information on those packages is missing in  
> the log you sent.
>
> It is possibly a locale issue (non-UTF-8 strings in the  
> shapefile?), so you might like to try this in the C locale.
>
>
>>> > 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
>>>
>>> ______________________________________________
>>> R-help at stat.math.ethz.ch mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide http://www.R-project.org/posting- 
>>> guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>
>>
>
> -- 
> Brian D. Ripley,                  ripley at stats.ox.ac.uk
> Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
> University of Oxford,             Tel:  +44 1865 272861 (self)
> 1 South Parks Road,                     +44 1865 272866 (PA)
> Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list