0

I have a very similar problem to this question: GenomicRanges: C stack usage ... is too close to the limit

I'm receiving the error message that "C stack usage is too close to the limit" when I try to view a multipolygon shapefile that I've imported.

Most of the help with this error message relates to recursive functions, but if that is what is happening, I don't think it's my doing. Viewing an sf polygon normally is not an issue.

ranges <- st_read("Range maps/PRISM_shorebird_ranges_breeding", "PRISM_shorebird_ranges_breeding")
> View(ranges)
Error: C stack usage  40945840 is too close to the limit
Error: no more error handlers available (recursive errors?); invoking 'abort' restart
Error: C stack usage  40945840 is too close to the limit
Error: no more error handlers available (recursive errors?); invoking 'abort' restart

However, the object seems fine when I try to look at the data in other ways.

str(ranges)

Classes ‘sf’ and 'data.frame':  40 obs. of  7 variables:
 $ binomial  : chr  "Arenaria interpres" "Arenaria interpres" "Arenaria interpres" "Calidris alpina" ...
 $ presence  : num  1 1 1 1 1 1 1 1 1 1 ...
 $ origin    : num  1 1 1 1 1 1 1 1 1 1 ...
 $ seasonal  : num  1 2 2 2 1 2 1 2 2 2 ...
 $ dist_comm : chr  NA NA NA NA ...
 $ Shape_Area: num  4.92 272.49 424.3 200.75 7.66 ...
 $ geometry  :sfc_MULTIPOLYGON of length 40; first list element: List of 477
  ..$ :List of 1
  .. ..$ : num [1:762, 1:2] 8.99 8.99 9 9 8.98 ...
  ..$ :List of 1
     
........


  ..$ :List of 1
  .. ..$ : num [1:24, 1:2] 11.2 11.2 11.3 11.3 11.3 ...
  ..$ :List of 1
  .. ..$ : num [1:18, 1:2] 6.42 6.43 6.44 6.44 6.44 ...
  .. [list output truncated]
  ..- attr(*, "class")= chr [1:3] "XY" "MULTIPOLYGON" "sfg"
 - attr(*, "sf_column")= chr "geometry"
 - attr(*, "agr")= Factor w/ 3 levels "constant","aggregate",..: NA NA NA NA NA NA
  ..- attr(*, "names")= chr [1:6] "binomial" "presence" "origin" "seasonal" ...



ranges[1,]

Simple feature collection with 1 feature and 6 fields
geometry type:  MULTIPOLYGON
dimension:      XY
bbox:           xmin: 4.650085 ymin: 58.53088 xmax: 12.91248 ymax: 65.57788
geographic CRS: NAD83
            binomial presence origin seasonal dist_comm Shape_Area                       geometry
1 Arenaria interpres        1      1        1      <NA>   4.915708 MULTIPOLYGON (((8.985718 63...

I also don't think the object should be too big

object.size(ranges)
93727840 bytes (~95kb)

The solution in GenomicRanges: C stack usage ... is too close to the limit was that there were packages that hadn't been updated due to permission issues.

I too have some R packages in "C:/Program Files/R/R-4.0.3/library" that I cannot update because I don't have administrative privileges. Nor will I be able to change this, as it's a work computer.

Any suggestions as to how I might resolve this problem?

canderson156
  • 1,045
  • 10
  • 24
  • Ask your admins to update those packages. I am not at all familiar with your tool chain, but I would also investigate whether I could increase the stack size for that program. – jwdonahue Feb 04 '21 at 21:08
  • I've seen this issue before regarding the `print()` method of some functions, so I don't think it's an issue with stack size per-se. Especially given the obejct is very small. – SymbolixAU Feb 04 '21 at 21:38
  • The reason I'm asking for an alternative solution that doesn't involve the admin is because it is a pain and limits my autonomy. I'd prefer a different solution if it were available. All the help threads I've read said not to increase C stack size in R. – canderson156 Feb 05 '21 at 15:29
  • So when you saw this before was there any solution @SymbolixAU ? – canderson156 Feb 05 '21 at 15:34
  • I honestly can't remember the solution. I see you can view 1 row with `ranges[1, ]`; do you know the maximum number of rows you can view? For example, does `ranges[1:20, ]` give an error? And can you narrow it down to a specific row that causes the error? – SymbolixAU Feb 05 '21 at 23:42

0 Answers0