Convert raster to im object
up vote
0
down vote
favorite
I would like to convert a raster to an im object but have so far been unable to do so.
Here is a reproducible example:
Create raster layer and add data to it:
r.toy <- raster(ncol=40, nrow=20)
r.toy <- rnorm(n=ncell(r.toy))
Plot the raster:
plot(r.toy)
Convert to image:
r.toy.im <- as.im(r.toy)
I receive the following error:
Error in as.im.default(r.toy) : Can't convert X to a pixel image
raster spatstat
add a comment |
up vote
0
down vote
favorite
I would like to convert a raster to an im object but have so far been unable to do so.
Here is a reproducible example:
Create raster layer and add data to it:
r.toy <- raster(ncol=40, nrow=20)
r.toy <- rnorm(n=ncell(r.toy))
Plot the raster:
plot(r.toy)
Convert to image:
r.toy.im <- as.im(r.toy)
I receive the following error:
Error in as.im.default(r.toy) : Can't convert X to a pixel image
raster spatstat
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I would like to convert a raster to an im object but have so far been unable to do so.
Here is a reproducible example:
Create raster layer and add data to it:
r.toy <- raster(ncol=40, nrow=20)
r.toy <- rnorm(n=ncell(r.toy))
Plot the raster:
plot(r.toy)
Convert to image:
r.toy.im <- as.im(r.toy)
I receive the following error:
Error in as.im.default(r.toy) : Can't convert X to a pixel image
raster spatstat
I would like to convert a raster to an im object but have so far been unable to do so.
Here is a reproducible example:
Create raster layer and add data to it:
r.toy <- raster(ncol=40, nrow=20)
r.toy <- rnorm(n=ncell(r.toy))
Plot the raster:
plot(r.toy)
Convert to image:
r.toy.im <- as.im(r.toy)
I receive the following error:
Error in as.im.default(r.toy) : Can't convert X to a pixel image
raster spatstat
raster spatstat
asked Nov 10 at 23:48
Carrie Perkins
263
263
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
You just need to load the maptools package which can convert many spatial
formats in R:
library(raster)
library(spatstat)
library(maptools)
r.toy <- raster(ncol=40, nrow=20)
r.toy <- rnorm(n=ncell(r.toy))
r.toy.im <- as.im(r.toy)
plot(r.toy.im)
Created on 2018-11-11 by the reprex package (v0.2.1)
Thank you, I didn't realize that maptools had to be loaded! However, I just tried to do the same thing, this time converting a polygon into an im object and received the same error message, despite maptools being loaded. Is polygon not a suitable data type to be converted to im?
– Carrie Perkins
Nov 11 at 2:25
Correct. Polygon should be converted toowin
.
– Ege Rubak
Nov 11 at 8:37
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
You just need to load the maptools package which can convert many spatial
formats in R:
library(raster)
library(spatstat)
library(maptools)
r.toy <- raster(ncol=40, nrow=20)
r.toy <- rnorm(n=ncell(r.toy))
r.toy.im <- as.im(r.toy)
plot(r.toy.im)
Created on 2018-11-11 by the reprex package (v0.2.1)
Thank you, I didn't realize that maptools had to be loaded! However, I just tried to do the same thing, this time converting a polygon into an im object and received the same error message, despite maptools being loaded. Is polygon not a suitable data type to be converted to im?
– Carrie Perkins
Nov 11 at 2:25
Correct. Polygon should be converted toowin
.
– Ege Rubak
Nov 11 at 8:37
add a comment |
up vote
0
down vote
You just need to load the maptools package which can convert many spatial
formats in R:
library(raster)
library(spatstat)
library(maptools)
r.toy <- raster(ncol=40, nrow=20)
r.toy <- rnorm(n=ncell(r.toy))
r.toy.im <- as.im(r.toy)
plot(r.toy.im)
Created on 2018-11-11 by the reprex package (v0.2.1)
Thank you, I didn't realize that maptools had to be loaded! However, I just tried to do the same thing, this time converting a polygon into an im object and received the same error message, despite maptools being loaded. Is polygon not a suitable data type to be converted to im?
– Carrie Perkins
Nov 11 at 2:25
Correct. Polygon should be converted toowin
.
– Ege Rubak
Nov 11 at 8:37
add a comment |
up vote
0
down vote
up vote
0
down vote
You just need to load the maptools package which can convert many spatial
formats in R:
library(raster)
library(spatstat)
library(maptools)
r.toy <- raster(ncol=40, nrow=20)
r.toy <- rnorm(n=ncell(r.toy))
r.toy.im <- as.im(r.toy)
plot(r.toy.im)
Created on 2018-11-11 by the reprex package (v0.2.1)
You just need to load the maptools package which can convert many spatial
formats in R:
library(raster)
library(spatstat)
library(maptools)
r.toy <- raster(ncol=40, nrow=20)
r.toy <- rnorm(n=ncell(r.toy))
r.toy.im <- as.im(r.toy)
plot(r.toy.im)
Created on 2018-11-11 by the reprex package (v0.2.1)
answered Nov 11 at 1:06
Ege Rubak
1,7891511
1,7891511
Thank you, I didn't realize that maptools had to be loaded! However, I just tried to do the same thing, this time converting a polygon into an im object and received the same error message, despite maptools being loaded. Is polygon not a suitable data type to be converted to im?
– Carrie Perkins
Nov 11 at 2:25
Correct. Polygon should be converted toowin
.
– Ege Rubak
Nov 11 at 8:37
add a comment |
Thank you, I didn't realize that maptools had to be loaded! However, I just tried to do the same thing, this time converting a polygon into an im object and received the same error message, despite maptools being loaded. Is polygon not a suitable data type to be converted to im?
– Carrie Perkins
Nov 11 at 2:25
Correct. Polygon should be converted toowin
.
– Ege Rubak
Nov 11 at 8:37
Thank you, I didn't realize that maptools had to be loaded! However, I just tried to do the same thing, this time converting a polygon into an im object and received the same error message, despite maptools being loaded. Is polygon not a suitable data type to be converted to im?
– Carrie Perkins
Nov 11 at 2:25
Thank you, I didn't realize that maptools had to be loaded! However, I just tried to do the same thing, this time converting a polygon into an im object and received the same error message, despite maptools being loaded. Is polygon not a suitable data type to be converted to im?
– Carrie Perkins
Nov 11 at 2:25
Correct. Polygon should be converted to
owin
.– Ege Rubak
Nov 11 at 8:37
Correct. Polygon should be converted to
owin
.– Ege Rubak
Nov 11 at 8:37
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53244549%2fconvert-raster-to-im-object%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown