exposurejapan.py 1.7 KB
Newer Older
Simantini Shinde's avatar
Simantini Shinde committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env python3

# Copyright (C) 2021:
#   Helmholtz-Zentrum Potsdam Deutsches GeoForschungsZentrum GFZ
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
# General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.


import logging
import sys
22
import sqlite3
23
from database import JapanDatabase  # pylint: disable=E0611,E0401
24

Simantini Shinde's avatar
Simantini Shinde committed
25
26
27
28
29
30
31
32
33
34
35
36

# Add a logger printing error, warning, info and debug messages to the screen
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
logger.addHandler(logging.StreamHandler(sys.stdout))


def main():

    # Example logging output
    logger.info("exposurejapan started")

37
38
39
    db = JapanDatabase("test.sqlite", "/usr/lib64/mod_spatialite.so.7")

    try:
40
        db.connect()
41
42
43
44
    except sqlite3.OperationalError:
        logger.warning("Spatialite extension cannot be loaded. Exiting ...")
        exit()
    db.create_tables()
45
46
    db.read_districts_and_boundaries("data/Boundary.gpkg")
    db.import_exposure_data(
47
        "data/population_sub_municipal.csv",
shinde's avatar
shinde committed
48
        "data/e039_3e.xlsx",
49
        "data/e008_3e.xlsx",
shinde's avatar
shinde committed
50
51
        "data/e011_2e.xlsx",
        "data/e014e.xlsx",
52
    )
53

Simantini Shinde's avatar
Simantini Shinde committed
54
55
56
57
58
59
    # Leave the program
    sys.exit()


if __name__ == "__main__":
    main()