Free Disk Space Error Trying to Extract Elevation Raster

65 Views Asked by At

I am trying to create an elevation raster in order to calculate terrain ruggedness index (TRI) for a set of point data. My set of point data is somewhat large (14,630 observations) and spans most of the southwest US. Example code below:

#load packages
library(geodata)
library(elevatr)
library(raster)

#simulate point data
longitude<-runif(n=14630, min=-115.4333, max=-108.6997)
latitude<-runif(n=14630, min=32.45918, max=37.20805)
pts<-data.frame(longitude,latitude)

#change dataframe to a spatial points object
coordinates(pts) = c("longitude", "latitude") # specify column names
class(pts)

#definining the lonlat projection
prj_dd <- "+proj=longlat +datum=NAD83"


#download a raster layer using the spatialpoints object as input
#zoom specifies the resolution
elevation <- get_elev_raster(pts, z = 13,prj=prj_dd,override_size_check=TRUE) 

The issue is that when I use the get_elev_raster function from the elevatr package, I keep getting the following error:

Error in sf::gdal_utils(util = "warp", source = files, destination = destfile, : gdal_utils warp: an error occured

In addition: Warning message:

In CPL_gdalwarp(source, destination, options, oo, doo, quiet, "-overwrite" %in% : GDAL Error 3: C:\Users\name\AppData\Local\Temp\Rtmps3PYwn\file32b8e4c79d6.tif: Free disk space available is 8839901184 bytes, whereas 21476933632 are at least necessary. You can disable this check by defining the CHECK_DISK_FREE_SPACE configuration option to FALSE.

This leads me to believe that the raster I am trying to download is too large. Am I right about that, and if so, is there any way I can reduce the size of the raster while still getting the necessary elevation data (elevation of the cell containing point data as well as its eight surrounding cells) or free up disk space? Thanks!

0

There are 0 best solutions below