We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In reference to https://stackoverflow.com/questions/74934891/specifying-layers-when-using-rast-type-xyz-to-convert-data-frame-to-spatra and facing a similar need, I think that, considering terra supports multilayer SpatRaster objects, it would be most natural having the option rast(x,type="xylz") where "l" would stand for layer, thus letting the user simply run, eg,
rast(x,type="xylz")
library(terra) set.seed(0) df <- data.frame(longitude=rep(seq(10,19,1), 3), latitude=rep(seq(10, 19,1), 3), date= as.Date(rep(c("2012-01-01", "2012-02-01", "2012-03-01"), each=10)), vals=rnorm(30,10,5)) x <- rast(df, type="xylz")
And the corresponding option xyl=TRUE would be appreciated in as.data.frame() to include a layer column within a "long" df format.
xyl=TRUE
as.data.frame()
The text was updated successfully, but these errors were encountered:
a6e9f38
Thanks, I have implemented both.
library(terra) set.seed(0) df <- data.frame(longitude=rep(seq(10,19,1), 3), latitude=rep(seq(10, 19,1), 3), date= as.Date(rep(c("2012-01-01", "2012-02-01", "2012-03-01"), each=10)), vals=rnorm(30,10,5)) x <- rast(df, type="xylz") x #class : SpatRaster #dimensions : 10, 10, 3 (nrow, ncol, nlyr) #resolution : 1, 1 (x, y) #extent : 9.5, 19.5, 9.5, 19.5 (xmin, xmax, ymin, ymax) #coord. ref. : #source(s) : memory #names : vals.1, vals.2, vals.3 #min values : 2.30025, 3.812308, 3.577003 #max values : 22.02327, 13.817967, 15.428847 #time (days) : 2012-01-01 to 2012-03-01 as.data.frame(x, wide=F, time=T) |> head() # layer time values #1 vals.1 2012-01-01 22.023267 #2 vals.1 2012-01-01 9.971164 #3 vals.1 2012-01-01 8.526398 #4 vals.1 2012-01-01 5.357165 #5 vals.1 2012-01-01 2.300250 #6 vals.1 2012-01-01 12.073207
Sorry, something went wrong.
No branches or pull requests
In reference to
https://stackoverflow.com/questions/74934891/specifying-layers-when-using-rast-type-xyz-to-convert-data-frame-to-spatra
and facing a similar need, I think that, considering terra supports multilayer SpatRaster objects, it would be most natural
having the option
rast(x,type="xylz")
where "l" would stand for layer, thus letting the user simply run, eg,
And the corresponding option
xyl=TRUE
would be appreciated in
as.data.frame()
to include a layer column within a "long" df format.The text was updated successfully, but these errors were encountered: