.TH t.rast.aggregate.ds 1grass "" "GRASS 7.8.5" "GRASS GIS User's Manual" .SH NAME \fI\fBt.rast.aggregate.ds\fR\fR \- Aggregates data of an existing space time raster dataset using the time intervals of a second space time dataset. .SH KEYWORDS temporal, aggregation, raster, time .SH SYNOPSIS \fBt.rast.aggregate.ds\fR .br \fBt.rast.aggregate.ds \-\-help\fR .br \fBt.rast.aggregate.ds\fR [\-\fBn\fR] \fBinput\fR=\fIname\fR \fBsample\fR=\fIname\fR [\fBtype\fR=\fIname\fR] \fBoutput\fR=\fIname\fR \fBbasename\fR=\fIstring\fR [\fBsuffix\fR=\fIstring\fR] \fBmethod\fR=\fIstring\fR [\fBoffset\fR=\fIinteger\fR] [\fBnprocs\fR=\fIinteger\fR] [\fBsampling\fR=\fIname\fR[,\fIname\fR,...]] [\fBwhere\fR=\fIsql_query\fR] [\-\-\fBoverwrite\fR] [\-\-\fBhelp\fR] [\-\-\fBverbose\fR] [\-\-\fBquiet\fR] [\-\-\fBui\fR] .SS Flags: .IP "\fB\-n\fR" 4m .br Register Null maps .IP "\fB\-\-overwrite\fR" 4m .br Allow output files to overwrite existing files .IP "\fB\-\-help\fR" 4m .br Print usage summary .IP "\fB\-\-verbose\fR" 4m .br Verbose module output .IP "\fB\-\-quiet\fR" 4m .br Quiet module output .IP "\fB\-\-ui\fR" 4m .br Force launching GUI dialog .SS Parameters: .IP "\fBinput\fR=\fIname\fR \fB[required]\fR" 4m .br Name of the input space time raster dataset .IP "\fBsample\fR=\fIname\fR \fB[required]\fR" 4m .br Time intervals from this space time dataset (raster, vector or raster3d) are used for aggregation computation .IP "\fBtype\fR=\fIname\fR" 4m .br Type of the space time dataset from which aggregation will be copied .br Options: \fIstrds, stvds, str3ds\fR .br Default: \fIstrds\fR .IP "\fBoutput\fR=\fIname\fR \fB[required]\fR" 4m .br Name of the output space time raster dataset .IP "\fBbasename\fR=\fIstring\fR \fB[required]\fR" 4m .br Basename of the new generated output maps .br A numerical suffix separated by an underscore will be attached to create a unique identifier .IP "\fBsuffix\fR=\fIstring\fR" 4m .br Suffix to add at basename: set \(cqgran\(cq for granularity, \(cqtime\(cq for the full time format, \(cqnum\(cq for numerical suffix with a specific number of digits (default %05) .br Default: \fIgran\fR .IP "\fBmethod\fR=\fIstring\fR \fB[required]\fR" 4m .br Aggregate operation to be performed on the raster maps .br Options: \fIaverage, count, median, mode, minimum, min_raster, maximum, max_raster, stddev, range, sum, variance, diversity, slope, offset, detcoeff, quart1, quart3, perc90, quantile, skewness, kurtosis\fR .br Default: \fIaverage\fR .IP "\fBoffset\fR=\fIinteger\fR" 4m .br Offset that is used to create the output map ids, output map id is generated as: basename_ (count + offset) .br Default: \fI0\fR .IP "\fBnprocs\fR=\fIinteger\fR" 4m .br Number of r.mapcalc processes to run in parallel .br Default: \fI1\fR .IP "\fBsampling\fR=\fIname[,\fIname\fR,...]\fR" 4m .br The method to be used for sampling the input dataset .br Options: \fIequal, overlaps, overlapped, starts, started, finishes, finished, during, contains\fR .br Default: \fIcontains\fR .IP "\fBwhere\fR=\fIsql_query\fR" 4m .br WHERE conditions of SQL statement without \(cqwhere\(cq keyword used in the temporal GIS framework .br Example: start_time > \(cq2001\-01\-01 12:30:00\(cq .SH DESCRIPTION \fIt.rast.aggregate.ds\fR works like t.rast.aggregate but instead of defining a fixed granularity for temporal aggregation the time intervals of all maps registered in a second space time dataset (can be STRDS, STR3DS or STVDS) are used to aggregate the maps of the input space time raster dataset. .SH NOTES The sampling method must be specified from the sampler dataset point of view. It defines the temporal relationships between intervals of the sampling dataset and the input space time raster dataset. .SH EXAMPLES .SS Precipitation aggregation In this example we create 7 raster maps that will be registered in a single space time raster dataset named \fIprecipitation_daily\fR using a daily temporal granularity. The names of the raster maps are stored in a text file that is used for raster map registration. .PP A space time vector dataset is created out of two vector maps with different temporal resolution. The maps are created using v.random. The first map has a granule of 3 days the second a granule of 4 days. .PP The space time raster dataset \fIprecipitation_daily\fR with daily temporal granularity will be aggregated using the space time vector dataset resulting in the output space time raster dataset \fIprecipitation_agg\fR. The aggregation method is set to \fIsum\fR to accumulate the precipitation values of all intervals in the space time vector dataset. The sampling option assures that only raster maps that are temporally during the time intervals of the space time vector dataset are considered for computation. Hence the option is set to contains (time stamped vector map layers temporally \fBcontain\fR the raster map layers): .br .nf \fC MAPS=\(dqmap_1 map_2 map_3 map_4 map_5 map_6 map_7\(dq for map in ${MAPS} ; do r.mapcalc expression=\(dq${map} = 1\(dq echo ${map} >> map_list.txt done t.create type=strds temporaltype=absolute \(rs output=precipitation_daily \(rs title=\(dqDaily precipitation\(dq \(rs description=\(dqTest dataset with daily precipitation\(dq t.register \-i type=raster input=precipitation_daily \(rs file=map_list.txt start=\(dq2012\-08\-20\(dq increment=\(dq1 days\(dq t.info type=strds input=precipitation_daily +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- Space Time Raster Dataset \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ | | +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- Basic information \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ | Id: ........................ precipitation_daily@PERMANENT | Name: ...................... precipitation_daily | Mapset: .................... PERMANENT | Creator: ................... soeren | Temporal type: ............. absolute | Creation time: ............. 2014\-11\-23 16:48:17.686979 | Modification time:.......... 2014\-11\-23 16:48:18.302978 | Semantic type:.............. mean +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- Absolute time \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ | Start time:................. 2012\-09\-10 00:00:00 | End time:................... 2012\-09\-17 00:00:00 | Granularity:................ 1 day | Temporal type of maps:...... interval +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- Spatial extent \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ | North:...................... 80.0 | South:...................... 0.0 | East:.. .................... 120.0 | West:....................... 0.0 | Top:........................ 0.0 | Bottom:..................... 0.0 +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- Metadata information \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ | Raster register table:...... raster_map_register_3225725979b14b5db343a00835b882c7 | North\-South resolution min:. 10.0 | North\-South resolution max:. 10.0 | East\-west resolution min:... 10.0 | East\-west resolution max:... 10.0 | Minimum value min:.......... 1.0 | Minimum value max:.......... 1.0 | Maximum value min:.......... 1.0 | Maximum value max:.......... 1.0 | Aggregation type:........... None | Number of registered maps:.. 7 | | Title: | Daily precipitation | Description: | Test dataset with daily precipitation | Command history: | # 2014\-11\-23 16:48:17 | t.create type=\(dqstrds\(dq temporaltype=\(dqabsolute\(dq | output=\(dqprecipitation_daily\(dq title=\(dqDaily precipitation\(dq | description=\(dqTest dataset with daily precipitation\(dq | # 2014\-11\-23 16:48:18 | t.register \-i type=\(dqrast\(dq input=\(dqprecipitation_daily\(dq | file=\(dqmap_list.txt\(dq start=\(dq2012\-08\-20\(dq increment=\(dq1 days\(dq | +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ v.random output=points_1 n=20 v.random output=points_2 n=20 t.create type=stvds temporaltype=absolute \(rs output=points \(rs title=\(dqPoints\(dq \(rs description=\(dqPoints for aggregation\(dq t.register \-i type=vector input=points \(rs map=points_1 start=\(dq2012\-08\-20\(dq increment=\(dq3 days\(dq t.register \-i type=vector input=points \(rs map=points_2 start=\(dq2012\-08\-23\(dq increment=\(dq4 days\(dq t.info type=stvds input=points +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- Space Time Vector Dataset \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ | | +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- Basic information \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ | Id: ........................ points@PERMANENT | Name: ...................... points | Mapset: .................... PERMANENT | Creator: ................... soeren | Temporal type: ............. absolute | Creation time: ............. 2014\-11\-23 16:48:49.193903 | Modification time:.......... 2014\-11\-23 16:48:50.185671 | Semantic type:.............. mean +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- Absolute time \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ | Start time:................. 2012\-08\-20 00:00:00 | End time:................... 2012\-08\-27 00:00:00 | Granularity:................ 1 day | Temporal type of maps:...... interval +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- Spatial extent \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ | North:...................... 79.283411 | South:...................... 5.724954 | East:.. .................... 118.881168 | West:....................... 0.016755 | Top:........................ 0.0 | Bottom:..................... 0.0 +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- Metadata information \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ | Vector register table:...... vector_map_register_6f02d33e0ee243d1a521aaaca39ecb31 | Number of points ........... 40 | Number of lines ............ 0 | Number of boundaries ....... 0 | Number of centroids ........ 0 | Number of faces ............ 0 | Number of kernels .......... 0 | Number of primitives ....... 40 | Number of nodes ............ 0 | Number of areas ............ 0 | Number of islands .......... 0 | Number of holes ............ 0 | Number of volumes .......... 0 | Number of registered maps:.. 2 | | Title: | Points | Description: | Points for aggregation | Command history: | # 2014\-11\-23 16:48:49 | t.create type=\(dqstvds\(dq temporaltype=\(dqabsolute\(dq | output=\(dqpoints\(dq title=\(dqPoints\(dq description=\(dqPoints for aggregation\(dq | # 2014\-11\-23 16:48:49 | t.register \-i type=\(dqvect\(dq input=\(dqpoints\(dq | map=\(dqpoints_1\(dq start=\(dq2012\-08\-20\(dq increment=\(dq3 days\(dq | # 2014\-11\-23 16:48:50 | t.register \-i type=\(dqvect\(dq input=\(dqpoints\(dq | map=\(dqpoints_2\(dq start=\(dq2012\-08\-23\(dq increment=\(dq4 days\(dq | +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ t.rast.aggregate.ds input=precipitation_daily \(rs output=precipitation_agg \(rs sample=points type=stvds \(rs basename=prec_agg \(rs method=sum sampling=contains t.support input=precipitation_agg \(rs title=\(dqAggregated precipitation\(dq \(rs description=\(dqAggregated precipitation dataset\(dq t.info type=strds input=precipitation_agg +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- Space Time Raster Dataset \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ | | +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- Basic information \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ | Id: ........................ precipitation_agg@PERMANENT | Name: ...................... precipitation_agg | Mapset: .................... PERMANENT | Creator: ................... soeren | Temporal type: ............. absolute | Creation time: ............. 2014\-11\-23 16:53:23.488799 | Modification time:.......... 2014\-11\-23 16:53:28.714886 | Semantic type:.............. mean +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- Absolute time \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ | Start time:................. 2012\-08\-20 00:00:00 | End time:................... 2012\-08\-27 00:00:00 | Granularity:................ 1 day | Temporal type of maps:...... interval +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- Spatial extent \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ | North:...................... 80.0 | South:...................... 0.0 | East:.. .................... 120.0 | West:....................... 0.0 | Top:........................ 0.0 | Bottom:..................... 0.0 +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- Metadata information \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ | Raster register table:...... raster_map_register_7b025eb7431747c98c5c1ad971e8c282 | North\-South resolution min:. 10.0 | North\-South resolution max:. 10.0 | East\-west resolution min:... 10.0 | East\-west resolution max:... 10.0 | Minimum value min:.......... 3.0 | Minimum value max:.......... 4.0 | Maximum value min:.......... 3.0 | Maximum value max:.......... 4.0 | Aggregation type:........... sum | Number of registered maps:.. 2 | | Title: | Aggregated precipitation | Description: | Aggregated precipitation dataset | Command history: | # 2014\-11\-23 16:53:23 | t.rast.aggregate.ds input=\(dqprecipitation_daily\(dq | output=\(dqprecipitation_agg\(dq sample=\(dqpoints\(dq type=\(dqstvds\(dq basename=\(dqprec_agg\(dq | method=\(dqsum\(dq sampling=\(dqcontains\(dq | # 2014\-11\-23 16:53:28 | t.support input=\(dqprecipitation_agg\(dq | title=\(dqAggregated precipitation\(dq | description=\(dqAggregated precipitation dataset\(dq | +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ \fR .fi .SS MODIS satellite sensor daily data aggregation to 8 days In this example the aggregation from daily data to eight days is shown. This \(dqeight\-day week\(dq is used in some MODIS satellite sensor products. .br .nf \fC # NOTE: the example is written in shell language # create maps every 8 days as seed maps for year in \(gaseq 2000 2001\(ga ; do for doy in \(gaseq \-w 1 8 365\(ga ; do r.mapcalc \-s expression=\(dq8day_${year}_${doy} = rand(0.0,40.0)\(dq done done # From de name of each map, we take year and doy, and convert it # to a YYYY\-MM\-DD date for start and end, and create a file with # mapnames, start date and end date g.list type=raster pattern=8day_20??_* > names_list for NAME in \(gacat names_list\(ga ; do # Parse YEAR=\(gaecho $NAME | cut \-d\(cq_\(cq \-f2\(ga DOY=\(gaecho $NAME | cut \-d\(cq_\(cq \-f3\(ga # convert YYYY_DOY to YYYY\-MM\-DD DOY=\(gaecho \(dq$DOY\(dq | sed \(cqs/^0*//\(cq\(ga doy_end=0 if [ $DOY \-le \(dq353\(dq ] ; then doy_end=$(( $DOY + 8 )) elif [ $DOY \-eq \(dq361\(dq ] ; then if [ $[$YEAR % 4] \-eq 0 ] && [ $[$YEAR % 100] \-ne 0 ] || [ $[$YEAR % 400] \-eq 0 ] ; then doy_end=$(( $DOY + 6 )) else doy_end=$(( $DOY + 5 )) fi fi DATE_START=\(gadate \-d \(dq${YEAR}\-01\-01 +$(( ${DOY} \- 1 ))days\(dq +%Y\-%m\-%d\(ga DATE_END=\(gadate \-d \(dq${YEAR}\-01\-01 +$(( ${doy_end} \-1 ))days\(dq +%Y\-%m\-%d\(ga # text file with mapnames, start date and end date echo \(dq$NAME|$DATE_START|$DATE_END\(dq >> list_map_start_end_time.txt done # check the list created. cat list_map_start_end_time.txt 8day_2000_001|2000\-01\-01|2000\-01\-09 8day_2000_009|2000\-01\-09|2000\-01\-17 \&... 8day_2000_353|2000\-12\-18|2000\-12\-26 8day_2000_361|2000\-12\-26|2001\-01\-01 8day_2001_001|2001\-01\-01|2001\-01\-09 8day_2001_009|2001\-01\-09|2001\-01\-17 \&... 8day_2001_345|2001\-12\-11|2001\-12\-19 8day_2001_353|2001\-12\-19|2001\-12\-27 8day_2001_361|2001\-12\-27|2002\-01\-01 # all maps except for the last map in each year represent 8\-days # intervals. But the aggregation starts all over again every # January 1st. # create 8\-day MODIS\-like strds t.create type=strds temporaltype=absolute \(rs output=8day_ts title=\(dq8 day time series\(dq \(rs description=\(dqSTRDS with MODIS like 8 day aggregation\(dq # register maps t.register type=raster input=8day_ts \(rs file=list_map_start_end_time.txt # check t.info input=8day_ts t.rast.list input=8day_ts # finally, copy the aggregation to a daily time series t.rast.aggregate.ds input=daily_ts sample=8day_ts \(rs output=8day_agg basename=8day_agg method=average \(rs sampling=contains suffix=gran # add metadata t.support input=8day_agg \(rs title=\(dq8 day aggregated ts\(dq \(rs description=\(dq8 day MODIS\-like aggregated dataset\(dq # check map list in newly created aggregated strds t.rast.list input=8day_agg name|mapset|start_time|end_time 8day_agg_2000_01_01|modis|2000\-01\-01 00:00:00|2000\-01\-09 00:00:00 8day_agg_2000_01_09|modis|2000\-01\-09 00:00:00|2000\-01\-17 00:00:00 8day_agg_2000_01_17|modis|2000\-01\-17 00:00:00|2000\-01\-25 00:00:00 \&... 8day_agg_2000_12_18|modis|2000\-12\-18 00:00:00|2000\-12\-26 00:00:00 8day_agg_2000_12_26|modis|2000\-12\-26 00:00:00|2001\-01\-01 00:00:00 8day_agg_2001_01_01|modis|2001\-01\-01 00:00:00|2001\-01\-09 00:00:00 \&... 8day_agg_2001_12_11|modis|2001\-12\-11 00:00:00|2001\-12\-19 00:00:00 8day_agg_2001_12_19|modis|2001\-12\-19 00:00:00|2001\-12\-27 00:00:00 8day_agg_2001_12_27|modis|2001\-12\-27 00:00:00|2002\-01\-01 00:00:00 \fR .fi .SH SEE ALSO \fI t.rast.aggregate, t.create, t.info \fR .SH AUTHOR Sören Gebbert, Thünen Institute of Climate\-Smart Agriculture .SH SOURCE CODE .PP Available at: t.rast.aggregate.ds source code (history) .PP Main index | Temporal index | Topics index | Keywords index | Graphical index | Full index .PP © 2003\-2020 GRASS Development Team, GRASS GIS 7.8.5 Reference Manual