-
Notifications
You must be signed in to change notification settings - Fork 1
/
run.py
73 lines (56 loc) · 2.34 KB
/
run.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
from ast import Str
from email.policy import default
import os
import sys
import argparse
import typing
from typing import Union
import yaml
import logging
from utils.file_management import get_footprints, initialize, save_data
from utils.data_collection.earthengine.manage import manage
def create_datadir(data_path:str):
os.makedirs(data_path, exist_ok=True)
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Process some integers.')
parser.add_argument('--data_dir', type=str, default='data')
parser.add_argument('--city', type=str, default=None)
parser.add_argument('--settings', type=str, default='settings.yml')
parser.add_argument('--projection_epsg', type=str, default='EPSG:3857') # pseudo-mercator, which is in meters but not perfect for distance calculations
parser.add_argument('--default_epsg', type=str, default='EPSG:4326')
parser.add_argument('--export', action='store_true')
parser.add_argument('--sample', action='store_true')
parser.add_argument(
"--log-level",
default=logging.INFO,
type=lambda x: getattr(logging, x),
help="Configure the logging level."
)
args = parser.parse_args()
logging.basicConfig(
format='%(asctime)s,%(msecs)d %(levelname)-8s [%(filename)s:%(lineno)d] %(message)s',
datefmt='%Y-%m-%d:%H:%M:%S',
level=args.log_level
)
logger = logging.getLogger(__name__)
config:dict = vars(args)
logger.info("Command Line Configuration: {}".format(config))
base_dir:str = os.path.dirname(os.path.realpath(__file__))
config, city_path = initialize(
base_dir=base_dir,
data_dir=args.data_dir,
city=args.city,
settings=args.settings,
commandline_settings=config
)
logger.info("Full Configuration File: {}".format(config))
# now into the management code - first want to get the building footprints and the regional statistics
footprints = get_footprints(city_path=city_path)
if config['sample'] == True:
logger.info("Segmenting sample for code testing...")
footprints = footprints.head(5)
logger.info("Processing {} footprints...".format(len(footprints)))
results = manage(footprints, **config)
logger.info('Saving files....')
save_data(results, city_path=city_path, **config)
logger.info('Saved!')