-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild_landslide_data.py
48 lines (40 loc) · 2.03 KB
/
build_landslide_data.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
from model.landslideModel import LandslideRecord, LandslideDownloadImageData
import pandas as pd
def countByLandslideSize(landslideRecords):
print(len(landslideRecords))
countLarge = countMedium = countVeryLarge = countSmall = countExtraLarge = countOther = 0
for record in landslideRecords:
if record.size == "Medium" or record.size == "medium":
countMedium += 1
elif record.size == "Large" or record.size == "large":
countLarge += 1
elif record.size == "Very_large":
countVeryLarge += 1
elif record.size == "Small" or record.size == "small":
countSmall += 1
elif record.size == "Extra_large" or record.size == "EXTRA_LARGE" or record.size == "Extra Large":
countExtraLarge += 1
else:
countOther +=1
print("Other size: ", record.size)
print("Landslide number of Small size: ", countSmall)
print("Landslide number of Medium size: ", countMedium)
print("Landslide number of Large size: ", countLarge)
print("Landslide number of Very large size: ", countVeryLarge)
print("Landslide number of Extra large size: ", countExtraLarge)
print("Landslide number of another size: ", countOther)
def readRecordData(input_file):
glc_data = pd.read_csv(input_file)
# print(glc_data.shape)
landslides = []
for index, recordItem in glc_data.iterrows():
landslideRecord = LandslideRecord(record_id=recordItem['id'], lat=recordItem['latitude'], lng=recordItem['longitude'],
eventDate=recordItem['date_'], size=recordItem['landslide1'],
country=recordItem['countrynam'], near=recordItem['near'], distance=recordItem['distance'])
# landslideRecord.printOut()
landslides.append(landslideRecord)
return landslides
if __name__ == "__main__":
input_path_from_glcdata = "./landslidedata.csv"
landslideRecords = readRecordData(input_path_from_glcdata)
countByLandslideSize(landslideRecords)