Skip to content

v.what.strds.timestamp

Uploads space time raster dataset values to the attribute table at positions of vector points in space and time.

v.what.strds.timestamp [-i] input=name layer=string timestamp_column=name column=name [where=sql_query] strds=name [,name,...] [t_where=sql_query] [--verbose] [--quiet] [--qq] [--ui]

Example:

v.what.strds.timestamp input=name layer=1 timestamp_column=name column=name strds=name

grass.script.run_command("v.what.strds.timestamp", input, layer="1", timestamp_column, column, where=None, strds, t_where=None, flags=None, verbose=False, quiet=False, superquiet=False)

Example:

gs.run_command("v.what.strds.timestamp", input="name", layer="1", timestamp_column="name", column="name", strds="name")

Parameters

input=name [required]
    Name of input vector map
    Or data source for direct OGR access
layer=string [required]
    Layer number or name
    Vector features can have category values in different layers. This number determines which layer to use. When used with direct OGR access this is the layer name.
    Default: 1
timestamp_column=name [required]
    Column of input vector map containing time stamps for temoral sampling of STRDS
    Name of attribute column
column=name [required]
    Column of input vector map to which raster values are written
    Column will be added if it does not exists or updated otherwise
where=sql_query
    Where-clause for filtering points in input vector map used for sampling
    Example: income < 1000 and population >= 10000
strds=name [,name,...] [required]
    Name of the input space time raster datasets
t_where=sql_query
    WHERE conditions of SQL statement without 'where' keyword used in the temporal GIS framework
    Temporal where-clause for selecting a subset of raster maps from STRDS for sampling (Default: The temporal bounding box of the input vector points)
-i
    Interpolate raster values from the four nearest pixels

--help
    Print usage summary
--verbose
    Verbose module output
--quiet
    Quiet module output
--qq
    Very quiet module output
--ui
    Force launching GUI dialog

input : str, required
    Name of input vector map
    Or data source for direct OGR access
    Used as: input, vector, name
layer : str, required
    Layer number or name
    Vector features can have category values in different layers. This number determines which layer to use. When used with direct OGR access this is the layer name.
    Used as: input, layer
    Default: 1
timestamp_column : str, required
    Column of input vector map containing time stamps for temoral sampling of STRDS
    Name of attribute column
    Used as: input, dbcolumn, name
column : str, required
    Column of input vector map to which raster values are written
    Column will be added if it does not exists or updated otherwise
    Used as: input, dbcolumn, name
where : str, optional
    Where-clause for filtering points in input vector map used for sampling
    Example: income < 1000 and population >= 10000
    Used as: input, sql_query, sql_query
strds : str | list[str], required
    Name of the input space time raster datasets
    Used as: input, strds, name
t_where : str, optional
    WHERE conditions of SQL statement without 'where' keyword used in the temporal GIS framework
    Temporal where-clause for selecting a subset of raster maps from STRDS for sampling (Default: The temporal bounding box of the input vector points)
    Used as: sql_query
flags : str, optional
    Allowed values: i
    i
        Interpolate raster values from the four nearest pixels

verbose: bool, optional
    Verbose module output
    Default: False
quiet: bool, optional
    Quiet module output
    Default: False
superquiet: bool, optional
    Very quiet module output
    Default: False

DESCRIPTION

v.what.strds.timestamp matches points with a timestamp in the attribute table (timestamp_column) (e.g. recordings from stationary (temperature logger, wildlife camera traps) or non-stationary sensors (e.g GPS collars)) with Space Time Raster Datasets (STRDS) based on point locaitions in space and time. Raster values at the specific space-time position are written into the user-defined column in the attribute table of the input vector map.

NOTES

The SQLite DB backend does not provide specific date/datetime datatypes. However, text columns with ISO formated date strings are supported for the timestamp_column as well.

Curretnly, only STRDS with absolute temporal type are supported.

EXAMPLE

This example is based on the MODIS LST raster time series sample dataset (mapset "modis_lst") available for the North Carolina sample location which can be downloaded from the GRASS GIS website.

# Check time MODIS LST raster time series to sample
t.rast.list LST_Day_monthly@modis_lst

# Set computational region to first raster map of the time series
g.region -up raster=MOD11B3.A2015001.h11v05.single_LST_Day_6km \
    align=MOD11B3.A2015001.h11v05.single_LST_Day_6km

# Create sampling points map with timestamp column for sampling time
echo "cat,sampling_time,x,y
1,2015-01-12,-125870.664090128,591821.149756026
2,2015-02-01,77667.7974483332,571718.585653462
3,2015-02-27,351565.233345769,481257.047191923
4,2015-03-10,565154.976935513,375718.585653462
5,2015-04-07,366642.156422692,277718.585653462
6,2015-05-22,178180.617961154,363154.483089359
7,2015-06-12,12334.464115,395821.149756026
8,2016-03-04,112847.28462782,204846.790781667
9,2016-05-12,311360.105140641,26436.5343714103
10,2017-01-03,467154.976935513,8846.79078166676
11,2018-01-01,600334.464115,129462.175397051
12,2016-06-07,690796.002576538,262641.662576539
13,2016-08-16,685770.361550897,441051.918986795
14,2016-12-11,625462.669243205,594333.970268846" > sampling_points.txt

# Import sampling points
v.in.ascii in=sampling_points.txt out=sampling_points x=3 y=4 cat=1 \
    columns='cat int, sampling_time date, x double precision, y double precision' \
     separator="," skip=1

# Assign LST values to sampling points at time of sampling
v.what.strds.timestamp input=sampling_points \
    timestamp_column=sampling_time column=lst_at_sampling_time \
    strds=LST_Day_monthly@modis_lst

# Check result
v.db.select sampling_points
cat|sampling_time|x|y|lst_at_sampling_time
1|2015-01-12|-125870.664090128|591821.149756026|13811
2|2015-02-01|77667.7974483332|571718.585653462|13486
3|2015-02-27|351565.233345769|481257.047191923|13793
4|2015-03-10|565154.976935513|375718.585653462|14355
5|2015-04-07|366642.156422692|277718.585653462|14565
6|2015-05-22|178180.617961154|363154.483089359|14864
7|2015-06-12|12334.464115|395821.149756026|15091
8|2016-03-04|112847.28462782|204846.790781667|14641
9|2016-05-12|311360.105140641|26436.5343714103|14982
10|2017-01-03|467154.976935513|8846.79078166676|
11|2018-01-01|600334.464115|129462.175397051|
12|2016-06-07|690796.002576538|262641.662576539|15052
13|2016-08-16|685770.361550897|441051.918986795|15052
14|2016-12-11|625462.669243205|594333.970268846|13920

# Check result for point with category 5
r.what -n map=MOD11B3.A2015091.h11v05.single_LST_Day_6km@modis_lst \
    coordinates=366642.156422692,277718.585653462

# add extra column for LST in degree Celsius
v.db.addcolumn map=sampling_points column="lst_celsius double precision"
# rescale original MODIS LST to degree Celsius
v.db.update map=sampling_points column="lst_celsius" query_column="lst_at_sampling_time * 0.02 - 273.15"
v.db.select sampling_points

SEE ALSO

v.what.rast, v.what.strds, r.connectivity.corridors

AUTHOR

Stefan Blumentrath, Norwegian Institute for Nature Research (NINA)
Written for the 2018 IRSAE GRASS GIS course at Studenterhytta, Oslo

SOURCE CODE

Available at: v.what.strds.timestamp source code (history)
Latest change: Thursday Feb 20 13:02:26 2025 in commit 53de819