Comments (4)
Thanks for opening this in a new issue..
It seems like a common enough problem, adding temporal information to a raster stack, and I see your note in the vignette to use the setZ
argument in raster, for example:
setZ(s, ts, name= time )
, where s is the rasterstack, and ts is the range of dates of interest.
How can I set the ts with an 8 day interval, but always starts at Jan 01 with every year in the ts?
when I run:
ts <- seq(as.Date("2002-06-26"), as.Date("2017-06-26"), by="8 days")
the beginning of every year does not start on Jan 01, and I end up with ts being shorted than s -- if that makes sense?
from modistsp.
Hi,
first of all, note that you don't really need to create the stacks "by hand": MODIStsp provides you with ready-made time series in the "Time_Series/RData" subfolder (See http://lbusett.github.io/MODIStsp/articles/output.html#virtual-multi-band-outputs)
You can open those using something like:
in__file <- ..../my_moditsp_folder/Time_Series/MOD13Q1_MYD13Q1_NDVI_49_2000_353_2015_RData.RData"
indata <- get(load(in__file))
those files already have the "time information" saved, both in the bandnames and in the "Z" attribute:
times <- raster::getZ(indata)
I recon that:
- this is probably not sufficiently documented (I'll update the website when I have time) and,
- the current organization of the "Time_Series" subfolder is a mess, since all layers are saved in the same folder. I am already working on an improvement which will be available soon.
PS : Making a time series of dates that always start at DOY 1 is definitely possibile. A quick workaround would be to create one year as you did, then create the other by adding 365 * nĀ° of elapsed years (watch out for leap years)
from modistsp.
Hi,
Thank you for your notes on this.
The reason I am figuring this out manually is that I am trying to get 8 day observations by inter-leafing terra and aqua 16d data, and when I created the Rdata stack using MODIStsp I did not combine both (which is what I should have done).
In any case, I came up with the following way to add the time attribute to the rasterStack, using your notes on setZ
and the raster.pdf. Rather than create a sequence and deal with leap years, I did the following 2 steps:
-
parsed the date information from filenames such as (MXD13C1_EVI_2002_177.tif)
library(stringr) dd <- str_extract_all(dat, "\\d{3,4}") df <- data.frame(matrix(unlist(dd), nrow=691, byrow=T)) colnames(df) <- c("year","DOY")
-
convert DOY and year to Date:
ts <- as.Date(paste(df$year, df$DOY), format="%Y %j")
then I created a stack from my directory and added the Zvalue
library(raster) s <- stack(dir()) s <- setZ(s, ts, name= "time" )
then saved
save(s,file="~/Documents...RData
from modistsp.
Yes, this is definitely a better way... and it's more or less what we use internally while building the rasterstacks !
I may be mistaken, but (unless you renamed MODIStsp outputs) I think you could need to sort ts
in ascending order and then the results of dir()
on the basis of the order of ts
before calling stack
if you want a properly ordered time series. This because a directory listing on MODIStsp files gives you all terra files, and then all aqua files.
from modistsp.
Related Issues (20)
- MODIStsp GUI issues HOT 6
- KNDVI (expression) - MODIStsp HOT 3
- bounding box does not work HOT 1
- Error in .local(.Object, ...) when trying to use MODIStsp_extract HOT 2
- M*D17A3H server change HOT 2
- Update products HOT 5
- Problems of processing MCD19A1 and MCD19A3 HOT 1
- Timeout HOT 1
- Timeout MODIS server error when downloading HOT 4
- Problem with GUI in GitHub version 2.0.6.9000 of MODIStsp HOT 2
- Connection refused HOT 2
- How to download the NDVI-MODIS product of the version 6.1 using the package MODIStsp v.2.0.6 HOT 2
- The package doesn't work on the new Spectral Indexes I added HOT 1
- [SOLVED] MODIStsp package is showing Username and password invalid even when the same credentials are working for NASA earth data search website HOT 20
- Missing dependency for pkgdown HOT 2
- Fix image location for pkgdown HOT 7
- Call for maintainer HOT 9
- Issues related to product version update in #238 HOT 23
- Spatial packages update HOT 2
- Error: http server seems to be down! Please try again later. Aborting! HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ššš
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ā¤ļø Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from modistsp.