Stack of several Raster

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Stack of several Raster

Gaetan Martinelli
Good morning all,


I would need some advice to move forward.
I'm starting to use Rstudio to manipulate a climate data and intersect with a differents points on my map (table of 1000 points with 6 attributes).
Also, I have several raster. I have an ASCII file for each day of a year. For 30 years.


I tried to use the Stack function and then make the intersection with my 1000 points for one year :
 
fs <- list.files(path="N:/Climate-10km/Max_T/1960",
                 pattern = "asc$", full.names = TRUE)
s <- raster::stack(fs)
 
TMAX60 <- extract(s, DataPoints)
 
 
 
I'm stuck just at this part ...
My intersection is good, but the order of appearance of my different columns corresponding to my 366 files (1 year) does not make any sense. They are out of order.

My goal is to create a table with my 6 points attributes, and add a "Year" column and a "Days" column and finally a "Pixel values" column. For a year at first time and if possible doing this intersection for all my years.
 
I had the idea to do this for each year and then join my different produced tables.
In the end, I would have a huge table, but one that will allow me to do my analysis. By calculating this, I will get:
 
- 9 attributes (6 attributs points, Year, Day, TMax) and 10 980 000 lines (30 years (past) * 366 days * 1000 points).
 
Does this seem like a good approach to you ?
 
Do you have an idea that could allow me to do this task without going through multiple table operations with "Dplyr" ?

Do you have any advice for a better approach I could take?

Sorry if my English is not always appropriate. I'm not very used to talking in this language yet. I'm working on it. :) 

Thank you very much in advance to those who can help me.

Have a good day.

Gaëtan.

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: Stack of several Raster

Bede-Fazekas Ákos
Dear Gaëtan,

"order of appearance of my different columns corresponding to my 366
files (1 year) does not make any sense": do you mean that the order of
the columns in TMAX60 is not what you want? The column order should
match the order of the layers in your RasterStack. You can check it with:
names(s)
The order of the layers will correspond to the list of file names stored
in fs. So you should arrange the file names in the appropriate order,
and then you'll get columns in TMAX60 in the desired order. Maybe not
list.files() is the best fuction to use. If the file names follow a
regular pattern, then you can simply create the character vector of the
file names with paste() or paste0().

HTH,
Ákos Bede-FAzekas
Hungarian Academy of Sciences


2020.09.14. 18:40 keltezéssel, Gaetan Martinelli írta:

> Good morning all,
>
>
> I would need some advice to move forward.
> I'm starting to use Rstudio to manipulate a climate data and intersect
> with a differents points on my map (table of 1000 points with 6
> attributes).
> Also, I have several raster. I have an ASCII file for each day of a
> year. For 30 years.
>
>
> I tried to use the Stack function and then make the intersection with
> my 1000 points for one year :
> fs <- list.files(path="N:/Climate-10km/Max_T/1960",
>                  pattern = "asc$", full.names = TRUE)
> s <- raster::stack(fs)
> TMAX60 <- extract(s, DataPoints)
> I'm stuck just at this part ...
> My intersection is good, but the order of appearance of my different
> columns corresponding to my 366 files (1 year) does not make any
> sense. They are out of order.
>
> My goal is to create a table with my 6 points attributes, and add a
> "Year" column and a "Days" column and finally a "Pixel values" column.
> For a year at first time and if possible doing this intersection for
> all my years.
> I had the idea to do this for each year and then join my different
> produced tables.
> In the end, I would have a huge table, but one that will allow me to
> do my analysis. By calculating this, I will get:
> - 9 attributes (6 attributs points, Year, Day, TMax) and 10 980 000
> lines (30 years (past) * 366 days * 1000 points).
> Does this seem like a good approach to you ?
> Do you have an idea that could allow me to do this task without going
> through multiple table operations with "Dplyr" ?
>
> Do you have any advice for a better approach I could take?
>
> Sorry if my English is not always appropriate. I'm not very used to
> talking in this language yet. I'm working on it. :)
>
> Thank you very much in advance to those who can help me.
>
> Have a good day.
>
> Gaëtan.
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo


        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo