-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathsetup.py
78 lines (67 loc) · 1.94 KB
/
setup.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
# System
import copy
import csv
import sys
import os
import watermark
import pickle
import itertools
import random
import zipfile
from collections import defaultdict
import pprint
pp = pprint.PrettyPrinter(indent=4)
from tqdm.notebook import tqdm
import warnings
import shutil
# Math/Data
import math
import numpy as np
import pandas as pd
# Network
import igraph as ig
import networkx as nx
# Plotting
import matplotlib.pyplot as plt
from matplotlib import cm
import matplotlib
from matplotlib.collections import PatchCollection
from matplotlib.ticker import MaxNLocator
# Geo
import osmnx as ox
ox.settings.log_file = True
ox.settings.requests_timeout = 300
ox.settings.logs_folder = PATH["logs"]
import fiona
import shapely
from osgeo import gdal, osr
from haversine import haversine, haversine_vector
import pyproj
from shapely.geometry import Point, MultiPoint, LineString, Polygon, MultiLineString, MultiPolygon
import shapely.ops as ops
import geopandas as gpd
import geojson
# dict of placeid:placeinfo
# If a city has a proper shapefile through nominatim
# In case no (False), manual download of shapefile is necessary, see below
cities = {}
with open(PATH["parameters"] + 'cities.csv') as f:
csvreader = csv.DictReader(f, delimiter=';')
for row in csvreader:
cities[row['placeid']] = {}
for field in csvreader.fieldnames[1:]:
cities[row['placeid']][field] = row[field]
if debug:
print("\n\n=== Cities ===")
pp.pprint(cities)
print("==============\n\n")
# Create city subfolders
for placeid, placeinfo in cities.items():
for subfolder in ["data", "plots", "plots_networks", "results", "exports", "exports_json", "videos"]:
placepath = PATH[subfolder] + placeid + "/"
if not os.path.exists(placepath):
os.makedirs(placepath)
print("Successfully created folder " + placepath)
from IPython.display import Audio
sound_file = '../dingding.mp3'
print("Setup finished.\n")