Commit 6282935c authored by Tara Evaz Zadeh's avatar Tara Evaz Zadeh
Browse files

Fixed bugs for building exposure calculations

parent 949644e3
Pipeline #19167 passed with stage
in 1 minute and 51 seconds
...@@ -116,7 +116,7 @@ def get_exposure_per_tile( ...@@ -116,7 +116,7 @@ def get_exposure_per_tile(
"structural_complete", "structural_complete",
] ]
tile_id = "origin_id" tile_id = "origin_id"
csv_writer.writerow(title) csv_writer.writerow(title)
for i in range(cell_ids.shape[0]): for i in range(cell_ids.shape[0]):
cell_id = cell_ids.loc[i][0] cell_id = cell_ids.loc[i][0]
......
...@@ -112,7 +112,7 @@ def damageCalculator_TileVersion( ...@@ -112,7 +112,7 @@ def damageCalculator_TileVersion(
/M008_exposure_Attica_GDE_visual_v001_sat_27f_by_cell_reOrder.csv" /M008_exposure_Attica_GDE_visual_v001_sat_27f_by_cell_reOrder.csv"
- exposure_type: (string), optional - exposure_type: (string), optional
{‘cell’, ‘OBM’}, optional'. cell by default. {‘cell’, ‘building’}. Cell by default.
- method: (string), optional - method: (string), optional
{‘linear’, ‘nearest’, ‘cubic’}, optional'. Linear by default. {‘linear’, ‘nearest’, ‘cubic’}, optional'. Linear by default.
...@@ -186,10 +186,10 @@ def damageCalculator_TileVersion( ...@@ -186,10 +186,10 @@ def damageCalculator_TileVersion(
lat = lats.iloc[asset] lat = lats.iloc[asset]
asset_id = asset_ids.iloc[asset] asset_id = asset_ids.iloc[asset]
origin_id = origin_ids.iloc[asset] origin_id = origin_ids.iloc[asset]
# In case of `exposure_type == "OBM"`, not only the geometry, but also the # In case of `exposure_type == "building"`, not only the geometry, but also the
# respective cell ID (in which the asset is located), is extracted # respective cell ID (in which the asset is located), is extracted
# using `origin_id_to_geometry_map` # using `origin_id_to_geometry_map`
if exposure_type == "OBM": if exposure_type == "building":
[geometry, respective_cell_id] = origin_id_to_geometry_map[origin_id] [geometry, respective_cell_id] = origin_id_to_geometry_map[origin_id]
else: else:
geometry = origin_id_to_geometry_map[origin_id] geometry = origin_id_to_geometry_map[origin_id]
...@@ -214,13 +214,13 @@ def damageCalculator_TileVersion( ...@@ -214,13 +214,13 @@ def damageCalculator_TileVersion(
for h in a: for h in a:
dmg_by_asset.insert(h, "") dmg_by_asset.insert(h, "")
# Append results # Append results
if exposure_type == "OBM": if exposure_type == "building":
asset = [ asset = [
geometry, geometry,
"", "",
origin_id, origin_id,
"", "",
"cell_" + respective_cell_id, respective_cell_id,
"", "",
asset_id, asset_id,
"", "",
......
...@@ -180,19 +180,19 @@ def origin_id_to_geometry(geometry_source, exposure_type): ...@@ -180,19 +180,19 @@ def origin_id_to_geometry(geometry_source, exposure_type):
""" """
Creates a dictionary of Origin-ids and their polygons. Creates a dictionary of Origin-ids and their polygons.
The input map 'geometry_source' contains the mapping for each The input map 'geometry_source' contains the mapping for each
Origin-id to a polygon along with its Cell-id if it's an OBM geometry source Origin-id to a polygon along with its cell-id if it's a building geometry source
as the 'origin_id_to_geometry_map'. as the 'origin_id_to_geometry_map'.
Input: Input:
------ ------
- exposure_type: (string) - exposure_type: (string)
Either 'OBM' or 'cell' Either 'building' or 'cell'
- geometry_source: (csv.reader) - geometry_source: (csv.reader)
Origin-id to geometry file map with semicolon as the delimiter, Origin-id to geometry file map with semicolon as the delimiter,
following the format: following the format:
['OriginID'; 'geometry'; 'cell_ID']. 'cell_ID' would only be available if ['OriginID'; 'geometry'; 'cell_ID']. 'cell_ID' would only be available if
your input geometry belongs to the OBM data(single buildings). 'cell_ID' the input geometry belongs to the building data(single buildings). 'cell_ID'
here points to the cell that contains the geometry. here points to the cell that contains the geometry.
Example extract: Example extract:
...@@ -206,7 +206,7 @@ def origin_id_to_geometry(geometry_source, exposure_type): ...@@ -206,7 +206,7 @@ def origin_id_to_geometry(geometry_source, exposure_type):
23.6889 38.3416, 23.6889 38.3389)) 23.6889 38.3416, 23.6889 38.3389))
... ...
if you have OBM geometry source: if you have building geometry source:
>>> geometry_source >>> geometry_source
OSM_517924352;POLYGON((2641289.2688 4582010.1248,2641299.6772 OSM_517924352;POLYGON((2641289.2688 4582010.1248,2641299.6772
4582007.1292,2641304.1745 4582019.8887,2641294.4229 4582007.1292,2641304.1745 4582019.8887,2641294.4229
...@@ -270,7 +270,7 @@ def origin_id_to_geometry(geometry_source, exposure_type): ...@@ -270,7 +270,7 @@ def origin_id_to_geometry(geometry_source, exposure_type):
# to know if the geometry refers to single buildings instead of cells. # to know if the geometry refers to single buildings instead of cells.
# In this case we need to also know the cell_ID that this building geometry # In this case we need to also know the cell_ID that this building geometry
# is located in. # is located in.
if exposure_type == "OBM": if exposure_type == "building":
# Loop through the origin_id_to_geometry map # Loop through the origin_id_to_geometry map
for geometry_mapping_item in geometry_source: for geometry_mapping_item in geometry_source:
# Check if already one geometry for a given OriginId has been # Check if already one geometry for a given OriginId has been
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment