Skip to content

Instantly share code, notes, and snippets.

@krisbolton
Last active February 3, 2021 16:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krisbolton/3427f9bd24ecdd8abdc719b5f669ae0b to your computer and use it in GitHub Desktop.
Save krisbolton/3427f9bd24ecdd8abdc719b5f669ae0b to your computer and use it in GitHub Desktop.
Solution to R error "cannot allocate vector of size ..."

Problem

You recieve an error in R Studio "cannot allocate vector of size ...". Below is the full error:

Error: package or namespace load failed for ‘raster’ in .doLoadActions(where, attach): error in load action .A.1 for package raster: loadModule(module = "spmod", what = TRUE, env = ns, loadNow = TRUE): Unable to load module "spmod": cannot allocate vector of size 14274.2 Gb

N.B. the data was not actually 14,000 Gb.. issues surrounding data that large would be clear.

Solution

Install the Rcpp package. Yep, that simple. See the documentation for info on Rcpp.

install.package("Rcpp")

Context

I have a blog post detailing a step-by-step tutorial for generating 3D maps with satellite imagery in R, a masters student from Università Politecnica delle Marche got in touch having this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment