Getting started
After installation, the tool works fairly straightforward.
If you want to do a raster-based calculation, use the RasterScanner. If you want to do a vector-based calculation, use the VectorScanner.
Please find below examples using the example data stored on the GitHub.
RasterScanner
1import os
2
3# import the RasterScanner
4from damagescanner.core import RasterScanner
5
6# set paths to the data
7inun_map = os.path.join(data_path,'data','inundation','inundation_map.tif')
8landuse_map = os.path.join(data_path,'data','landuse','landuse_map.tif')
9curve_path = os.path.join(data_path,'data','curves','curves.csv')
10maxdam_path = os.path.join(data_path,'data','curves','maxdam.csv')
11
12# run the RasterScanner and return a pandas DataFrame with loss per land-use class
13loss_df = RasterScanner(landuse_map,inun_map,curve_path,maxdam_path)[0]
VectorScanner
1# import necessary packages
2import os
3import numpy
4import pandas
5
6# import the RasterScanner
7from damagescanner.core import VectorScanner
8
9# set paths to the data
10inun_map = os.path.join(data_path,'data','inundation','inundation_map.tif')
11landuse_map = os.path.join(data_path,'data','landuse','landuse.shp')
12
13# Create maximum damage dictionary
14maxdam = {"grass":5,
15 "forest":10,
16 "orchard":50,
17 "residential":200,
18 "industrial":300,
19 "retail":300,
20 "farmland":10,
21 "cemetery":15,
22 "construction":10,
23 "meadow":5,
24 "farmyard":5,
25 "scrub":5,
26 "allotments":10,
27 "reservoir":5,
28 "static_caravan":100,
29 "commercial":300}
30
31# Create some dummy curves that will match the land-use classes
32curves = numpy.array(
33 [[0,0],
34 [50,0.2],
35 [100,0.4],
36 [150,0.6],
37 [200,0.8],
38 [250,1]])
39
40curves = numpy.concatenate((curves,
41 numpy.transpose(numpy.array([curves[:,1]]*(len(maxdam)-1)))),
42 axis=1)
43
44curves = pandas.DataFrame(curves)
45curves.columns = ['depth']+list(maxdam.keys())
46curves.set_index('depth',inplace=True)
47
48# run the VectorScanner and return the landuse map with damage values
49loss_df = VectorScanner(landuse,inun_map,curves,maxdam)