diff --git a/examples/example_preprocessor/README.md b/examples/example_preprocessor/README.md new file mode 100644 index 0000000000000000000000000000000000000000..108eb49788ab7099234ed2e1aea3ab6df6f7cc37 --- /dev/null +++ b/examples/example_preprocessor/README.md @@ -0,0 +1,10 @@ +# Preprocessor example + +To run each example, execute the shell script (`run_XXX.sh`) in the respective folder. + +For simplicity and convenience, the resulting exposure database in the `import` folder is used as the input for the export example. This way, one can compare how an input exposure model in CSV format can turn into an extended exposure model (again in CSV format), using the `import` and then `export` commands provided by `preprocessor.py`. + +The resulting files created by either the `import` or `export` commands are named `reference_exposure_import_result.db` and +`reference_exposure_export_result.csv` respectively, and can be found in the relevant command folder. + +For more information on the definition and use of `preprocesor.py` and both its commands (`import` and `export`), please read the [manual.md](../../docs/manual.md). diff --git a/examples/example_preprocessor/export/data/exposure.db b/examples/example_preprocessor/export/data/exposure.db new file mode 100644 index 0000000000000000000000000000000000000000..bea2c6e96f041d7486779f619ecf4e244ca80a58 Binary files /dev/null and b/examples/example_preprocessor/export/data/exposure.db differ diff --git a/examples/example_preprocessor/export/reference_exposure_export_result.csv b/examples/example_preprocessor/export/reference_exposure_export_result.csv new file mode 100644 index 0000000000000000000000000000000000000000..881e49ece90a0e16f61a8c7b4cc60c89ad745618 --- /dev/null +++ b/examples/example_preprocessor/export/reference_exposure_export_result.csv @@ -0,0 +1,15 @@ +"id","lon","lat","taxonomy","number","structural","night","occupancy","admin_name","admin_id","tile_id","tile_geometry","building_id","building_geometry" +"GDE_Ind_65386",23.631797343377702,38.06329694059163,"CR/LFINF+CDM/H:2",0.224973,401840.352396,0.0,"Ind","GR_3515002","Aspropyrgos",2423204507,"POLYGON((23.630556 38.061111, 23.633333 38.061111, 23.633333 38.063889, 23.630556 38.063889, 23.630556 38.061111))",222934686,"MULTIPOLYGON(((23.630847 38.064601, 23.631049 38.064604, 23.631047 38.064762, 23.63171 38.064783, 23.631716 38.064613, 23.631816 38.064614, 23.632176 38.064626, 23.632202 38.063738, 23.632667 38.063738, 23.632669 38.063558, 23.632831 38.063558, 23.632857 38.06299, 23.63286 38.062905, 23.632862 38.062839, 23.63288 38.062074, 23.631034 38.062047, 23.631016 38.062812, 23.632092 38.062828, 23.632092 38.062887, 23.632088 38.062983, 23.631891 38.062982, 23.6309 38.062973, 23.630847 38.064601)))" +"GDE_Ind_65397",23.631329148602102,38.06165797757123,"MUR/LWAL+CDN/H:1",0.210144,339605.074644,0.0,"Ind","GR_3515002","Aspropyrgos",2423204507,"POLYGON((23.630556 38.061111, 23.633333 38.061111, 23.633333 38.063889, 23.630556 38.063889, 23.630556 38.061111))",222955279,"MULTIPOLYGON(((23.630928 38.061335, 23.630943 38.061879, 23.631999 38.061831, 23.631999 38.06172, 23.631925 38.061717, 23.631925 38.061697, 23.631786 38.061696, 23.631789 38.061674, 23.631349 38.061484, 23.631349 38.061393, 23.631145 38.061394, 23.631137 38.061328, 23.630928 38.061335)))" +"GDE_Ind_65394",23.631329148602102,38.06165797757123,"CR/LFINF+CDM/H:2",0.224973,401840.352396,0.0,"Ind","GR_3515002","Aspropyrgos",2423204507,"POLYGON((23.630556 38.061111, 23.633333 38.061111, 23.633333 38.063889, 23.630556 38.063889, 23.630556 38.061111))",222955279,"MULTIPOLYGON(((23.630928 38.061335, 23.630943 38.061879, 23.631999 38.061831, 23.631999 38.06172, 23.631925 38.061717, 23.631925 38.061697, 23.631786 38.061696, 23.631789 38.061674, 23.631349 38.061484, 23.631349 38.061393, 23.631145 38.061394, 23.631137 38.061328, 23.630928 38.061335)))" +"GDE_Ind_65390",23.631797343377702,38.06329694059163,"CR/LDUAL+CDH/H:9/9.0",0.037954,64564.119433,0.0,"Ind","GR_3515002","Aspropyrgos",2423204507,"POLYGON((23.630556 38.061111, 23.633333 38.061111, 23.633333 38.063889, 23.630556 38.063889, 23.630556 38.061111))",222934686,"MULTIPOLYGON(((23.630847 38.064601, 23.631049 38.064604, 23.631047 38.064762, 23.63171 38.064783, 23.631716 38.064613, 23.631816 38.064614, 23.632176 38.064626, 23.632202 38.063738, 23.632667 38.063738, 23.632669 38.063558, 23.632831 38.063558, 23.632857 38.06299, 23.63286 38.062905, 23.632862 38.062839, 23.63288 38.062074, 23.631034 38.062047, 23.631016 38.062812, 23.632092 38.062828, 23.632092 38.062887, 23.632088 38.062983, 23.631891 38.062982, 23.6309 38.062973, 23.630847 38.064601)))" +"GDE_Ind_65401",23.631329148602102,38.06165797757123,"W/LWAL+CDL/H:1",0.009929,16045.975096,0.0,"Ind","GR_3515002","Aspropyrgos",2423204507,"POLYGON((23.630556 38.061111, 23.633333 38.061111, 23.633333 38.063889, 23.630556 38.063889, 23.630556 38.061111))",222955279,"MULTIPOLYGON(((23.630928 38.061335, 23.630943 38.061879, 23.631999 38.061831, 23.631999 38.06172, 23.631925 38.061717, 23.631925 38.061697, 23.631786 38.061696, 23.631789 38.061674, 23.631349 38.061484, 23.631349 38.061393, 23.631145 38.061394, 23.631137 38.061328, 23.630928 38.061335)))" +"GDE_Com_916837",23.63105850055369,38.06522588570288,"CR/LFINF+CDN/H:1",0.476789,13483.297447,0.0,"Com","GR_3515002","Aspropyrgos",2423074907,"POLYGON((23.630556 38.063889, 23.633333 38.063889, 23.633333 38.066667, 23.630556 38.066667, 23.630556 38.063889))",222934685,"MULTIPOLYGON(((23.630828 38.065225, 23.630865 38.065262, 23.630866 38.065403, 23.631033 38.065406, 23.631079 38.065429, 23.631104 38.065442, 23.631133 38.065445, 23.631136 38.065361, 23.631246 38.065359, 23.631246 38.065291, 23.631296 38.065289, 23.631297 38.065168, 23.631238 38.065174, 23.631243 38.06505, 23.63086 38.065051, 23.63087 38.065199, 23.630828 38.065225)))" +"GDE_Com_916844",23.63105850055369,38.06522588570288,"MCF/LWAL+CDL/H:1",0.523211,12368.624886,0.0,"Com","GR_3515002","Aspropyrgos",2423074907,"POLYGON((23.630556 38.063889, 23.633333 38.063889, 23.633333 38.066667, 23.630556 38.066667, 23.630556 38.063889))",222934685,"MULTIPOLYGON(((23.630828 38.065225, 23.630865 38.065262, 23.630866 38.065403, 23.631033 38.065406, 23.631079 38.065429, 23.631104 38.065442, 23.631133 38.065445, 23.631136 38.065361, 23.631246 38.065359, 23.631246 38.065291, 23.631296 38.065289, 23.631297 38.065168, 23.631238 38.065174, 23.631243 38.06505, 23.63086 38.065051, 23.63087 38.065199, 23.630828 38.065225)))" +"GDE_Ind_63866",23.631795147649886,38.065282687591846,"CR/LFINF+CDM/H:2",0.398963,401840.352396,0.0,"Ind","GR_3515002","Aspropyrgos",2423074907,"POLYGON((23.630556 38.063889, 23.633333 38.063889, 23.633333 38.066667, 23.630556 38.066667, 23.630556 38.063889))",222934688,"MULTIPOLYGON(((23.631754 38.065254, 23.631779 38.065325, 23.631836 38.065312, 23.631812 38.06524, 23.631754 38.065254)))" +"GDE_Ind_63867",23.631795147649886,38.065282687591846,"CR/LFM+CDM/H:2",0.398963,401840.352396,0.0,"Ind","GR_3515002","Aspropyrgos",2423074907,"POLYGON((23.630556 38.063889, 23.633333 38.063889, 23.633333 38.066667, 23.630556 38.066667, 23.630556 38.063889))",222934688,"MULTIPOLYGON(((23.631754 38.065254, 23.631779 38.065325, 23.631836 38.065312, 23.631812 38.06524, 23.631754 38.065254)))" +"GDE_Ind_63872",23.631795147649886,38.065282687591846,"S/LFM+CDH/RME/H:1",0.202073,193838.596394,0.0,"Ind","GR_3515002","Aspropyrgos",2423074907,"POLYGON((23.630556 38.063889, 23.633333 38.063889, 23.633333 38.066667, 23.630556 38.066667, 23.630556 38.063889))",222934688,"MULTIPOLYGON(((23.631754 38.065254, 23.631779 38.065325, 23.631836 38.065312, 23.631812 38.06524, 23.631754 38.065254)))" +"GDE_Com_940019",23.631944444444454,38.06249999999999,"CR/LDUAL+CDH/H:1/15.0",28.3,61.832846,0.0,"Com","GR_3515002","Aspropyrgos",2423204507,"POLYGON((23.630556 38.061111, 23.633333 38.061111, 23.633333 38.063889, 23.630556 38.063889, 23.630556 38.061111))","-1","POINT EMPTY" +"GDE_Com_940036",23.631944444444454,38.06249999999999,"CR/LDUAL+CDM/H:1/8.0",12.5,61.832846,0.0,"Com","GR_3515002","Aspropyrgos",2423204507,"POLYGON((23.630556 38.061111, 23.633333 38.061111, 23.633333 38.063889, 23.630556 38.063889, 23.630556 38.061111))","-1","POINT EMPTY" +"GDE_Res_1036159",23.631944444444454,38.06249999999999,"CR/LDUAL+CDL/HBET:3-5/SOS/8.0",36.2,4254.296016,0.182922,"Res","GR_3515002","Aspropyrgos",2423204507,"POLYGON((23.630556 38.061111, 23.633333 38.061111, 23.633333 38.063889, 23.630556 38.063889, 23.630556 38.061111))","-1","POINT EMPTY" +"GDE_Ind_65405",23.631944444444454,38.06249999999999,"MUR/LWAL+CDN/H:1",60.9,1114022.10067,0.0,"Ind","GR_3515002","Aspropyrgos",2423204507,"POLYGON((23.630556 38.061111, 23.633333 38.061111, 23.633333 38.063889, 23.630556 38.063889, 23.630556 38.061111))","-1","POINT EMPTY" diff --git a/examples/example_preprocessor/export/run_preprocessor_export.sh b/examples/example_preprocessor/export/run_preprocessor_export.sh new file mode 100755 index 0000000000000000000000000000000000000000..bcf5f017727b23f633788bcf69e9c9aa01cbfb72 --- /dev/null +++ b/examples/example_preprocessor/export/run_preprocessor_export.sh @@ -0,0 +1 @@ +python3 ../../../utils/preprocessor.py export -o data/exposure.csv -d data/exposure.db -w diff --git a/examples/example_preprocessor/import/data/exposure.csv b/examples/example_preprocessor/import/data/exposure.csv new file mode 100644 index 0000000000000000000000000000000000000000..c3f4000bc90a5f3d82a742ba9fc99b9d445e8b9a --- /dev/null +++ b/examples/example_preprocessor/import/data/exposure.csv @@ -0,0 +1,15 @@ +id,lon,lat,taxonomy,number,structural,night,occupancy,admin_name,admin_ID,origin_id +GDE_Ind_65386,23.6317973417,38.063296952,CR/LFINF+CDM/H:2,0.224973135611,401840.352396,0.0,Ind,Aspropyrgos,GR_3515002,OSM_222934686 +GDE_Ind_65397,23.6313291488,38.061657978,MUR/LWAL+CDN/H:1,0.210143993123,339605.074644,0.0,Ind,Aspropyrgos,GR_3515002,OSM_222955279 +GDE_Ind_65394,23.6313291488,38.061657978,CR/LFINF+CDM/H:2,0.224973135611,401840.352396,0.0,Ind,Aspropyrgos,GR_3515002,OSM_222955279 +GDE_Ind_65390,23.6317973417,38.063296952,CR/LDUAL+CDH/H:9/9.0,0.0379540081668,64564.1194326,0.0,Ind,Aspropyrgos,GR_3515002,OSM_222934686 +GDE_Ind_65401,23.6313291488,38.061657978,W/LWAL+CDL/H:1,0.00992907801418,16045.9750957,0.0,Ind,Aspropyrgos,GR_3515002,OSM_222955279 +GDE_Com_916837,23.6310585005,38.0652258859,CR/LFINF+CDN/H:1,0.476788508,13483.2974468,0.0,Com,Aspropyrgos,GR_3515002,OSM_222934685 +GDE_Com_916844,23.6310585005,38.0652258859,MCF/LWAL+CDL/H:1,0.523211492,12368.6248861,0.0,Com,Aspropyrgos,GR_3515002,OSM_222934685 +GDE_Ind_63866,23.6317951476,38.0652826876,CR/LFINF+CDM/H:2,0.398963336,401840.352396,0.0,Ind,Aspropyrgos,GR_3515002,OSM_222934688 +GDE_Ind_63867,23.6317951476,38.0652826876,CR/LFM+CDM/H:2,0.398963336,401840.352396,0.0,Ind,Aspropyrgos,GR_3515002,OSM_222934688 +GDE_Ind_63872,23.6317951476,38.0652826876,S/LFM+CDH/RME/H:1,0.202073329,193838.596394,0.0,Ind,Aspropyrgos,GR_3515002,OSM_222934688 +GDE_Com_940019,23.6319444444,38.0625,CR/LDUAL+CDH/H:1/15.0,28.3,61.8328463283,0.0,Com,Aspropyrgos,GR_3515002,cell_2423204507 +GDE_Com_940036,23.6319444444,38.0625,CR/LDUAL+CDM/H:1/8.0,12.5,61.8328463283,0.0,Com,Aspropyrgos,GR_3515002,cell_2423204507 +GDE_Res_1036159,23.6319444444,38.0625,CR/LDUAL+CDL/HBET:3-5/SOS/8.0,36.2,4254.29601601,0.18292166398,Res,Aspropyrgos,GR_3515002,cell_2423204507 +GDE_Ind_65405,23.6319444444,38.0625,MUR/LWAL+CDN/H:1,60.9,1114022.10067,0.0,Ind,Aspropyrgos,GR_3515002,cell_2423204507 diff --git a/examples/example_preprocessor/import/data/geometries.csv b/examples/example_preprocessor/import/data/geometries.csv new file mode 100644 index 0000000000000000000000000000000000000000..c74dd1278ab1b6bcd48291a5c5cbc45deee3da3a --- /dev/null +++ b/examples/example_preprocessor/import/data/geometries.csv @@ -0,0 +1,5 @@ +origin_id;geometry;cell_id +OSM_222934686;POLYGON((2630573.85 4588555.73,2630596.33 4588556.2,2630596.12 4588578.51,2630669.87 4588581.55,2630670.58 4588557.43,2630681.72 4588557.58,2630721.85 4588559.31,2630724.67 4588433.81,2630776.41 4588433.81,2630776.64 4588408.29,2630794.66 4588408.29,2630797.58 4588327.99,2630797.91 4588316.05,2630798.17 4588306.66,2630800.18 4588198.5,2630594.68 4588194.65,2630592.66 4588302.81,2630712.48 4588305.06,2630712.5 4588313.49,2630712 4588327.06,2630690.04 4588326.82,2630579.71 4588325.58,2630573.85 4588555.73));cell_2423204507 +OSM_222955279;POLYGON((2630582.91 4588093.97,2630584.55 4588171,2630702.08 4588164.21,2630702.08 4588148.52,2630693.89 4588148.05,2630693.89 4588145.24,2630678.43 4588145.01,2630678.67 4588141.96,2630629.73 4588115.04,2630629.73 4588102.16,2630607.02 4588102.4,2630606.09 4588093.04,2630582.91 4588093.97));cell_2423204507 +OSM_222934688;POLYGON((2630674.77 4588648.17,2630677.62 4588658.21,2630683.92 4588656.37,2630681.31 4588646.11,2630674.77 4588648.17));cell_2423074907 +OSM_222934685;POLYGON((2630571.72 4588644.06,2630575.82 4588649.32,2630575.94 4588669.22,2630594.56 4588669.58,2630599.63 4588672.86,2630602.51 4588674.72,2630605.68 4588675.08,2630606.03 4588663.26,2630618.32 4588663.02,2630618.32 4588653.3,2630623.82 4588653.06,2630623.94 4588635.98,2630617.39 4588636.8,2630617.97 4588619.24,2630575.35 4588619.36,2630576.41 4588640.31,2630571.72 4588644.06));cell_2423074907 diff --git a/examples/example_preprocessor/import/reference_exposure_import_result.db b/examples/example_preprocessor/import/reference_exposure_import_result.db new file mode 100644 index 0000000000000000000000000000000000000000..165bb5dc51706396f8139f89e943f7a07776d75d Binary files /dev/null and b/examples/example_preprocessor/import/reference_exposure_import_result.db differ diff --git a/examples/example_preprocessor/import/run_preprocessor_import.sh b/examples/example_preprocessor/import/run_preprocessor_import.sh new file mode 100755 index 0000000000000000000000000000000000000000..9b668165265e6371b80934db8a4bc01c328bc8ce --- /dev/null +++ b/examples/example_preprocessor/import/run_preprocessor_import.sh @@ -0,0 +1 @@ +python3 ../../../utils/preprocessor.py import -g data/geometries.csv -i data/exposure.csv -d data/exposure_exampletest.db -w