[R-sig-Geo] Cumulate space time data over days
Edzer Pebesma
edzer.pebesma at uni-muenster.de
Mon Jul 20 13:45:16 CEST 2015
On 07/17/2015 06:48 PM, pierluigi de rosa wrote:
> Dear all,
>
> I'm have a simple question that I think should be easly to answer but I'm
> an R beginner anf I didn't find nothing exactly what I need.
>
> I have a STFDF that register rainfall data over 14 years in 30 monitoring
> stations.
> I need to evaluate for each day the cumulative rainfall of the 3 days
> before (or 72 hours) and than extract data where this cumulative value is
> above a threshold.
>
> How ca I reach that?
Since this is a pure time series problem, I'd try something along these
lines:
library(xts)
z = as(pioggieST1, "xts")
m = rollmean(z, 3, align = "right")
sel = m[apply(m > 300, 1, all),] # threshold 300
you may want to remove "any" with "all" if all stations should be above
the threshold of 300.
> Thanks
>
> Summary of my data is below
> Thanks
> Pierluigi
>
>> summary(pioggieST1)
> Object of class STFDF
> with Dimensions (s, t, attr): (30, 8401, 1)
> [[Spatial:]]
> Object of class SpatialPointsDataFrame
> Coordinates:
> min max
> coords.x1 2272679 2320496
> coords.x2 4698989 4821088
> Is projected: TRUE
> proj4string :
> [+proj=tmerc +lat_0=0 +lon_0=15 +k=0.9996 +x_0=2520000 +y_0=0 +ellps=intl
> +units=m +no_defs]
> Number of points: 30
> Data attributes:
> nome
> Allerona : 1
> Amelia : 1
> Attigliano : 1
> Avigliano_Umbro : 1
> Bastardo : 1
> Calvi_dell_Umbria: 1
> (Other) :24
> [[Temporal:]]
> Index timeIndex
> Min. :1991-01-01 Min. : 1
> 1st Qu.:1996-10-01 1st Qu.:2101
> Median :2002-07-02 Median :4201
> Mean :2002-07-02 Mean :4201
> 3rd Qu.:2008-04-01 3rd Qu.:6301
> Max. :2013-12-31 Max. :8401
> [[Data attributes:]]
> values
> Min. : 0.000
> 1st Qu.: 0.000
> Median : 0.000
> Mean : 1.489
> 3rd Qu.: 0.000
> Max. :273.000
>
>
--
Edzer Pebesma
Institute for Geoinformatics (ifgi), University of Münster,
Heisenbergstraße 2, 48149 Münster, Germany; +49 251 83 33081
Journal of Statistical Software: http://www.jstatsoft.org/
Computers & Geosciences: http://elsevier.com/locate/cageo/
Spatial Statistics Society http://www.spatialstatistics.info
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: OpenPGP digital signature
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20150720/30179479/attachment.bin>
More information about the R-sig-Geo
mailing list