1#!/usr/local/bin/python3.8
2# -*- coding: utf-8 -*-
3############################################################################
4#
5# MODULE:        t.rast.import
6# AUTHOR(S):     Soeren Gebbert
7#
8# PURPOSE:       Import a space time raster dataset
9# COPYRIGHT:     (C) 2011-2017 by the GRASS Development Team
10#
11#  This program is free software; you can redistribute it and/or modify
12#  it under the terms of the GNU General Public License as published by
13#  the Free Software Foundation; either version 2 of the License, or
14#  (at your option) any later version.
15#
16#  This program is distributed in the hope that it will be useful,
17#  but WITHOUT ANY WARRANTY; without even the implied warranty of
18#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19#  GNU General Public License for more details.
20#
21#############################################################################
22
23#%module
24#% description: Imports space time raster dataset.
25#% keyword: temporal
26#% keyword: import
27#% keyword: raster
28#% keyword: time
29#% keyword: create location
30#%end
31
32#%option G_OPT_F_INPUT
33#%end
34
35#%option G_OPT_STRDS_OUTPUT
36#%end
37
38#%option
39#% key: basename
40#% type: string
41#% label: Basename of the new generated output maps
42#% description: A numerical suffix separated by an underscore will be attached to create a unique identifier
43#% required: no
44#% multiple: no
45#% gisprompt:
46#%end
47
48#%option G_OPT_M_DIR
49#% key: directory
50#% description: Path to the extraction directory
51#% answer: /tmp
52#%end
53
54#%option
55#% key: title
56#% type: string
57#% description: Title of the new space time dataset
58#% required: no
59#% multiple: no
60#%end
61
62#%option
63#% key: description
64#% type: string
65#% description: Description of the new space time dataset
66#% required: no
67#% multiple: no
68#%end
69
70#%option
71#% key: location
72#% type: string
73#% description: Create a new location and import the data into it. Do not run this module in parallel or interrupt it when a new location should be created
74#% required: no
75#% multiple: no
76#%end
77
78#%option G_OPT_MEMORYMB
79#%end
80
81#%flag
82#% key: r
83#% description: Set the current region from the last map that was imported
84#%end
85
86#%flag
87#% key: l
88#% description: Link the raster files using r.external
89#%end
90
91#%flag
92#% key: e
93#% description: Extend location extents based on new dataset
94#%end
95
96#%flag
97#% key: o
98#% label: Override projection check (use current location's projection)
99#% description: Assume that the dataset has same projection as the current location
100#%end
101
102#%flag
103#% key: c
104#% description: Create the location specified by the "location" parameter and exit. Do not import the space time raster datasets.
105#%end
106
107import grass.script as grass
108
109
110def main():
111    # lazy imports
112    import grass.temporal as tgis
113
114    # Get the options
115    input = options["input"]
116    output = options["output"]
117    directory = options["directory"]
118    title = options["title"]
119    descr = options["description"]
120    location = options["location"]
121    base = options["basename"]
122    memory = options["memory"]
123    set_current_region = flags["r"]
124    link = flags["l"]
125    exp = flags["e"]
126    overr = flags["o"]
127    create = flags["c"]
128
129    tgis.init()
130
131    tgis.import_stds(input, output, directory, title, descr, location,
132                     link, exp, overr, create, "strds", base,
133                     set_current_region, memory)
134
135if __name__ == "__main__":
136    options, flags = grass.parser()
137    main()
138