-
Notifications
You must be signed in to change notification settings - Fork 168
/
Copy pathhd.esri2vector.py
executable file
·69 lines (58 loc) · 1.76 KB
/
hd.esri2vector.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
#!/usr/bin/env python3
############################################################################
#
# MODULE: hd.esri2vector
# AUTHOR(S): Matej Krejci ([email protected]
#
# COPYRIGHT: (C) 2016 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.
#
#############################################################################
# %module
# % description: Module for conversion Esri GeoJson to GRASS vector
# % keyword: database
# % keyword: hdfs
# % keyword: hive
# %end
# %option G_OPT_V_OUTPUT
# % key: out
# % required: yes
# %end
# %option
# % key: path
# % type: string
# % description: path to the folder with files.
# %end
# %option
# % key: attributes
# % type: string
# % description: list of attributes with datatype
# %end
import os
import sys
import grass.script as gs
from hdfsgrass.hdfs_grass_lib import GrassMapBuilderEsriToEsri
def main():
files = os.listdir(options["path"])
map_string = ""
# download and convert blocks of table
for block in files:
map = "%s_0%s" % (options["out"], block)
block = os.path.join(options["path"], block)
map_build = GrassMapBuilderEsriToEsri(block, map, options["attributes"])
try:
map_build.build()
map_string += "%s," % map
except Exception as e:
gs.warning("Error: %s\n Map < %s > conversion failed" % (e, block))
path, folder_name = os.path.split(options["path"])
gs.message(
"For merge map: v.patch output=%s -e --overwrite input=%s"
% (folder_name, map_string)
)
if __name__ == "__main__":
options, flags = gs.parser()
main()