Example - Plain version

This example illustrates the usage of the Plain version of SHIRE based on provided datasets. The foundations of the following illustrated example are indentical to the one described in Example - GUI version.

Similarly to the discussed GUI version example, where the focus was strongly focused on the initialisation of the process and less on the underlying principles, in the following the Python script settings.py will be discussed.

Datasets

All necessary datasets can be found in the Gitlab repository in the examples folder.
Geospatial datasets:
European Union’s Copernicus Land Monitoring Service information:
All datasets were edited. Imperviousness Density 2018 and Dominant Leaf Type 2018 were merged from smaller tiles and then stored in a netCDF4 file.
Landslide database:
Datenquelle Hangmuren-Datenbank, Eidg. Forschungsanstalt WSL, Forschungseinheit Gebirgshydrologie & Massenbewegungen (status October 2024).
The spatial coordinates of the landslide locations were transformed into WGS84 coordinates using QGIS.
Absence locations database:
Randomly sampled locations outside of a buffer zone around the entries in the landslide database. The database contains more absence locations than will be integrated into the example. This is intentional as both landslide as well as absence locations are removed during the training dataset generation process if one of their features contains a no data value. Having additional absence locations available allows SHIRE to integrate the number of absence locations as intended by the user.
Metadata files:
keys_to_include_examples.csv
data_summary_examples.csv

Launching SHIRE

Similarly to the GUI version, it is also recommended to launch SHIRE for the Plain version from the command line:

(venv) $ python shire.py

However, as the Plain version doesn’t use the Python package tkinter, it can be run from any Python editor. Before launching SHIRE, it is necessary to implement the information prompted for in the four GUIs (see Example - GUI version) in settings.py.

Settings file

In data/ there is a settings_template.py Python script which needs to be prepared before running SHIRE.

Beware!: When launching SHIRE, the settings.py file (rename the template after using it) must be in the same folder as the script shire.py, i.e. in the current folder structure src/plain_version/.

Each parameter declared in settings.py comes with a short description to make filling out the script easier. In the following, the content of settings.py file in the context of the example will be illustrated. The method export_variables does not need to be adapted. It is responsible for printing the settings to the logging file to make the premises under which the resulting map was produced traceable and whole process reproducible.

Sure! Here’s your long table converted into an HTML table format with left-aligned content in each cell:

This is my table
Parameter Description Value Type Example Values
training_dataset True if training dataset shall be created, else False Bool False
preprocessing Defines preprocessing approach: 'cluster', 'interpolation', 'no_interpolation' String 'no_interpolation'
train_from_scratch True for generation of training dataset from scratch, else False Bool True
train_delete True if feature(s) shall be removed from existing training dataset, else False. train_from_scratch=False and train_delete=False adds feature(s) to existing training dataset Bool False
prediction_dataset True if prediction dataset shall be created, else False Bool True
pred_from_scratch True for generation of prediction dataset from scratch, else False Bool False
pred_delete True if feature(s) shall be removed from existing prediction dataset, else False. pred_from_scratch=False and pred_delete=False adds feature(s) to existing prediction dataset Bool False
map_generation True if Random Forest model shall be trained and/or landslide susceptibility/hazard map shall be created Bool False
crs Coordinate Reference System, important metadata information Bool False
no_value No data value that indicates in the final map where prediction was not possible Bool False
random_seed Random seed Integer 42
resolution Goal resolution of the final map Integer 250
path_ml Reference path on the local machine or external hard drive to the base directory for storing SHIRE's products String '../../examples/'
data_summary_path Path to the *data_summary.csv* file String '../../examples/data_summary.csv'
key_to_include_path Path to the *keys_to_include.csv* file String '../../examples/keys_to_include.csv'
size Fraction of the training dataset to be used as test dataset float 0.25
path_train Path/directory to store created training dataset in String '../../examples/'
ohe True, if categorical variables shall be one-hot encoded, False for ordinal encoding Bool False
path_landslide_database Path a landslide database stored locally or on an external hard drive String '../../examples/
landslide_coordinates_wgs84.csv'
ID Name of the column in the landslide database that contains the ID of the instances String 'Ereignis-Nr'
landslide_database_x Name of the column in the landslide database that contains the longitude coordinates String 'X'
landslide_database_y Name of the column in the landslide database that contains the latitude coordinates String 'Y'
bounding_box Bounding box of map to be created ([ymax, ymin, xmin, xmax]) List [47.8, 45.8, 5.9, 10.5]
path_pred Path/directory to store created prediction dataset in String path_ml
RF_training True, if Random Forest model shall be trained from scratch, else False Bool True
RF_prediction True, if final map shall be generated, else False Bool True
not_included_pred_data Feature(s) to drop from the prediction dataset before applying the trained model to the prediction dataset List ['xcoord', 'ycoord']
not_included_train_data Feature(s) to drop from the training dataset before training the Random Forest model List []
num_trees Number of trees in the Random Forest Integer 100
criterion Evaluation criterion String 'gini'
depth Depth of a Random Forest tree Integer 20
model_to_save Name of model folder in model_database_dir to store the trained Random Forest model in. Will be created in model_database_dir String 'Switzerland_Map'
model_to_load Name of model folder that contains the model to be loaded for map production. Typically identical to model_to_save String 'Switzerland_Map'
model_database_dir Path on the local machine or external hard drive to the directory for storing the model folders String '../../examples/'
parallel If susceptibility/hazard shall be predicted in parallel Bool True