Skip to main content
Tweeted twitter.com/StackGIS/status/1323822310479040512
edited tags
Source Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

How to convert 'RasterBrick' Converting RasterBrick object to 'im'im object in R?

During script execution I need to convert 'RasterBrick' to 'im' object. Package 'geostatsp' is supposed to do this job:

library(geostatsp)
myraster = raster(matrix(1:100,10,10), xmn=0,xmx=10,ymn=0,ymx=10)
class(myraster)
>[1] "RasterLayer"
>attr(,"package")
>[1] "raster"

myIm = as.im(myraster)
class(myIm)
>[1] "im"

But when I try it with real data I catch an error:

library(geostatsp)

b <- brick(some_file)
r <- raster(b)
class(r)
>[1] "RasterLayer"
>attr(,"package")
>[1] "raster"

bim <- as.im(r)
>Error in .local(x, ...) : 'x' has no values

What causes this?

How to convert 'RasterBrick' object to 'im' object in R?

During script execution I need to convert 'RasterBrick' to 'im' object. Package 'geostatsp' is supposed to do this job:

library(geostatsp)
myraster = raster(matrix(1:100,10,10), xmn=0,xmx=10,ymn=0,ymx=10)
class(myraster)
>[1] "RasterLayer"
>attr(,"package")
>[1] "raster"

myIm = as.im(myraster)
class(myIm)
>[1] "im"

But when I try it with real data I catch an error:

library(geostatsp)

b <- brick(some_file)
r <- raster(b)
class(r)
>[1] "RasterLayer"
>attr(,"package")
>[1] "raster"

bim <- as.im(r)
>Error in .local(x, ...) : 'x' has no values

Converting RasterBrick object to im object in R

During script execution I need to convert 'RasterBrick' to 'im' object. Package 'geostatsp' is supposed to do this job:

library(geostatsp)
myraster = raster(matrix(1:100,10,10), xmn=0,xmx=10,ymn=0,ymx=10)
class(myraster)
>[1] "RasterLayer"
>attr(,"package")
>[1] "raster"

myIm = as.im(myraster)
class(myIm)
>[1] "im"

But when I try it with real data I catch an error:

library(geostatsp)

b <- brick(some_file)
r <- raster(b)
class(r)
>[1] "RasterLayer"
>attr(,"package")
>[1] "raster"

bim <- as.im(r)
>Error in .local(x, ...) : 'x' has no values

What causes this?

added 77 characters in body
Source Link
SS_Rebelious
  • 5.6k
  • 3
  • 28
  • 62

During script execution I need to convert 'RasterBrick' to 'im' object. Package 'geostatsp''geostatsp' is supposed to do this job:

library(geostatsp)
myraster = raster(matrix(1:100,10,10), xmn=0,xmx=10,ymn=0,ymx=10)
class(myraster)
>[1] "RasterLayer"
>attr(,"package")
>[1] "raster"

myIm = as.im(myraster)
class(myIm)
>[1] "im"

But when I try it with real data I catch an error:

library(geostatsp)

b <- brick(some_file)
r <- raster(b)
class(r)
>[1] "RasterLayer"
>attr(,"package")
>[1] "raster"

bim <- as.im(r)
>Error in .local(x, ...) : 'x' has no values

During script execution I need to convert 'RasterBrick' to 'im' object. Package 'geostatsp' is supposed to do this job:

library(geostatsp)
myraster = raster(matrix(1:100,10,10), xmn=0,xmx=10,ymn=0,ymx=10)
class(myraster)
>[1] "RasterLayer"
>attr(,"package")
>[1] "raster"

myIm = as.im(myraster)
class(myIm)
>[1] "im"

But when I try it with real data I catch an error:

library(geostatsp)

b <- brick(some_file)
r <- raster(b)
class(r)
>[1] "RasterLayer"
>attr(,"package")
>[1] "raster"

bim <- as.im(r)
>Error in .local(x, ...) : 'x' has no values

During script execution I need to convert 'RasterBrick' to 'im' object. Package 'geostatsp' is supposed to do this job:

library(geostatsp)
myraster = raster(matrix(1:100,10,10), xmn=0,xmx=10,ymn=0,ymx=10)
class(myraster)
>[1] "RasterLayer"
>attr(,"package")
>[1] "raster"

myIm = as.im(myraster)
class(myIm)
>[1] "im"

But when I try it with real data I catch an error:

library(geostatsp)

b <- brick(some_file)
r <- raster(b)
class(r)
>[1] "RasterLayer"
>attr(,"package")
>[1] "raster"

bim <- as.im(r)
>Error in .local(x, ...) : 'x' has no values
Source Link
SS_Rebelious
  • 5.6k
  • 3
  • 28
  • 62

How to convert 'RasterBrick' object to 'im' object in R?

During script execution I need to convert 'RasterBrick' to 'im' object. Package 'geostatsp' is supposed to do this job:

library(geostatsp)
myraster = raster(matrix(1:100,10,10), xmn=0,xmx=10,ymn=0,ymx=10)
class(myraster)
>[1] "RasterLayer"
>attr(,"package")
>[1] "raster"

myIm = as.im(myraster)
class(myIm)
>[1] "im"

But when I try it with real data I catch an error:

library(geostatsp)

b <- brick(some_file)
r <- raster(b)
class(r)
>[1] "RasterLayer"
>attr(,"package")
>[1] "raster"

bim <- as.im(r)
>Error in .local(x, ...) : 'x' has no values