Commit 77b03e08 authored by Cecilia Nievas's avatar Cecilia Nievas
Browse files

Changed order of tasks within export_to_OpenQuake_CSV for optimisation

parent 79215d60
Pipeline #47896 passed with stage
in 2 minutes and 17 seconds
......@@ -158,6 +158,17 @@ def export_to_OpenQuake_CSV(
quadtile_geom.to_file(os.path.join(output_path, filename_quadtiles), driver="GPKG")
for building_type in buildings_to_export:
# Identify the attribute of 'quadtile' that 'building_type' corresponds to
attribute_name = "%s_buildings" % (building_type.lower())
if hasattr(quadtile, attribute_name): # check if attribute exists
data = deepcopy(getattr(quadtile, attribute_name))
else:
continue
# There may be no buildings of this type (e.g. zero remainder buildings)
if data.shape[0] == 0:
continue
# Prefix of unique ID
prefix_id = "%s_%s_%s" % (quadkeys_group, occupancy_case, building_type)
......@@ -176,17 +187,6 @@ def export_to_OpenQuake_CSV(
else:
last_id = int(last_id_str.split("%s_" % (prefix_id))[-1])
# Identify the attribute of 'quadtile' that 'building_type' corresponds to
attribute_name = "%s_buildings" % (building_type.lower())
if hasattr(quadtile, attribute_name): # check if attribute exists
data = deepcopy(getattr(quadtile, attribute_name))
else:
continue
# There may be no buildings of this type (e.g. zero remainder buildings)
if data.shape[0] == 0:
continue
# Create additional output columns
data["id"] = [
"%s_%s" % (prefix_id, i) for i in range(last_id + 1, last_id + 1 + data.shape[0])
......
Supports Markdown
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