-
Notifications
You must be signed in to change notification settings - Fork 168
/
Copy patht.info.iso.py
86 lines (64 loc) · 1.92 KB
/
t.info.iso.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/env python3
"""
@module t.info.iso
@brief Module for creating metadata based on ISO for temporal maps
(C) 2014 by the GRASS Development Team
This program is free software under the GNU General Public License
(>=v2). Read the file COPYING that comes with GRASS for details.
@author Matej Krejci <matejkrejci gmail.com> (GSoC 2015)
"""
# %module
# % description: Lists information about space time datasets and maps.
# % keyword: temporal
# % keyword: metadata
# % keyword: extent
# %end
# %option G_OPT_STDS_INPUT
# % description: Name of an existing space time dataset or map
# %end
# %option G_OPT_STDS_TYPE
# % guidependency: input
# % guisection: Required
# % options: strds, str3ds, stvds, raster, raster_3d, vector
# %end
# %option G_OPT_F_OUTPUT
# % required: no
# %end
import os
import sys
import grass.script as gs
import grass.temporal as tgis
from grass.script import parser
gs.utils.set_path(modulename="wx.metadata", dirname="mdlib", path="..")
def main():
# Load metadata library
from mdlib.mdgrass import GrassMD
if not options["output"]:
destination = None
output_name = None
else:
destination, output_name = os.path.split(options["output"])
name = options["input"]
type_ = options["type"]
# Make sure the temporal database exists
tgis.init()
dbif, connected = tgis.init_dbif(None)
if name.find("@") >= 0:
id_ = name
else:
id_ = "{}@{}".format(name, gs.gisenv()["MAPSET"])
dataset = tgis.dataset_factory(type_, id_)
if not dataset.is_in_db(dbif):
gs.fatal(
_("Dataset <%s> not found in temporal database") % (id_),
)
md = GrassMD(id_, type=type_)
md.createTemporalISO()
md.saveXML(
path=destination,
xml_out_name=output_name,
overwrite=os.getenv("GRASS_OVERWRITE", False),
)
if __name__ == "__main__":
options, flags = parser()
sys.exit(main())