4

I am using RStudio with landsat package for computing and plotting the Bare Soil Line (BSL) on landsat tif image running on my HP Pavilion i7 laptop. The codes for running the BSL() function is as under:

b3 <- as.data.frame(raster("LT51500371993170ISP00_B3.TIF", na.rm=TRUE))
b4 <- as.data.frame(raster("LT51500371993170ISP00_B4.TIF", na.rm=TRUE))

bsl.1993 <- BSL(b3, b4, "quantile", ulimit=0.99, llimit=0.005)

I have received the error message when I write the code without na.rm=TRUE as by default argument is FALSE for na.rm. After using na.rm=TRUE I received the same message as under. But one thing I want to mention here although my system is 64 bit machine with 8GB RAM and running R-studio 32 bit version when I execute the code for whole tile of landsat RAM reaches up to approximatively 7GB, it gives the message to running the memory low message after 5 minutes of the execution then the same message appeared the second time as under:

Error in quantile.default(ratio43, llimit) : 
 missing values and NaN's not allowed if 'na.rm' is FALSE

Please suggest me the solution to solve this matter and how do I improve the low memory. I have also running the linux machine on VMware Workstation.

0

You need to scale your data between for values 0-255. The BSL function is adapted to work with Landsat data, which is scaled for these values. Not sure if this is helpful to you or not, just apply this scale function to your images and let me know what results you get.

function(x, x.min = old.min, x.max = old.max, new.min = 0, new.max = 255) {
if(is.null(x.min)) x.min = min(x)
if(is.null(x.max)) x.max = max(x)
new.min + (x - x.min) * ((new.max - new.min) / (x.max - x.min))}
  • 1
    There is are a few caveats that I am emailing Sarah Goslee over. The regression, in theory, would work on any bit-wise data but, to account for sensor saturation the code explicitly removes 255 values and if method == "minimum" forces the data range 0-254, which would only be relevant to 8-bit data. There is some hardcoding of 8-bit values that would be quite easy to change based on the data observed bit-depth. Also, if not 8-bit, the test statistic would be invalid. – Jeffrey Evans Mar 28 at 21:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.