[R-sig-Geo] spacetime : the challenge of image time series containing holes

Tom Gottfried tom.gottfried at wzw.tum.de
Sat Apr 9 18:40:30 CEST 2011


Hi,

see below

Am 09.04.2011 02:26, schrieb servet cizmeli:
> Greetings to all,
>
> I have monthly mean satellite image time series that come in a 4-column
> text file each.  I have dozens of such files. Every line correspond to a
> pixel that is projected onto a regular ISIN grid. The first column is
> the ISIN grid number (same coordinates for a given grid number in every
> file), the second column is the latitude, the third column is the
> longitude and the last column is the value of the satellite measurement.
> Every file contain a varying number of lines (no NAs), although the lat
> and lon associated for a given ISIN grid number is the same in every file.
>
> I read the examples related with the STFDF class and understood it.
> However this is not a good solution for me as I have a lot of holes in
> my data. I would therefore like to place these time series into an
> irregular STSDF spacetime format. I could not find any information on
> how to achieve that. I would appreciate it very much if you could help
> me construct the irregular STSDF (or STIDF?) object. How to instruct the
> STSDF function so that it understands what goes where?

> Below is a sample code that involves 3 image files, each containing
> different pixels. I do not have handy a complete list of a list of all
> grid numbers for which there is at least one pixel. But I could easily
> generate it by reading in every image in a same data frame and producing
> a list of the unique values of the first column. For now I construct a
> SpatialPoints object but eventually I will be working with SpatialPixels.
>
> thanks a lot for your kindly help.
> Best
> Servet
>
> library(sp)
> library(spacetime)
> img200206<- data.frame(rbind(
> c(10849178, -4.979167,      -19.99302,      1.1542897E-03),
> c(10849179, -4.979167,      -19.95120,      1.3418309E-03),
> c(10849180, -4.979167,      -19.90937,      1.3988283E-03)))
>
> img200207<- data.frame(rbind(
> c(10849178,  -4.979167,      -19.99302,      1.2843144E-03),
> c(10849179,  -4.979167,      -19.95120,      1.1260216E-03)))
>
> img200208<- data.frame(rbind(
> c(10849179,  -4.979167,      -19.95120,      1.5001300E-03),
> c(10849180,  -4.979167,      -19.90937,      1.4793734E-03)))
>
> coordinates(img200206)=c("X3","X2")
> coordinates(img200207)=c("X3","X2")
> coordinates(img200208)=c("X3","X2")
>
> time = xts(1:3, as.POSIXct(c("2002-06-01","2002-07-01","2002-08-01")))
>
> #This is where I am stuck at
> mySTSDF = STSDF(  ... )

there's surely a better way for constructing the index (depending on how 
you organise your input data), but for the example this should work:

sp <- SpatialPoints(unique(rbind(coordinates(img200206),
coordinates(img200207), coordinates(img200208))))
data <- rbind(img200206, img200207, img200208)@data
index <- matrix(c(1:3, 1:2, 2:3, rep(1, 3), rep(2,2), rep(3,2)), 	
nrow=nrow(data))
mySTSDF = STSDF(sp, time, data, index)

regards,
Tom

>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo



More information about the R-sig-Geo mailing list