Commit a6bf7a7c authored by Simantini Shinde's avatar Simantini Shinde
Browse files

Imported GEM taxonomy-based building classes

parent 5f5d46db
Pipeline #39639 passed with stage
in 1 minute and 51 seconds
......@@ -72,26 +72,30 @@ class JapanDatabase(SpatialiteDatabase):
def create_tables(self):
"""
Creates all necessary tables in the database. These are:
District : Stores the districts with their IDs, names and geometries
DwellingNumber : Stores the number of dwellings depending on building types,
construction material and number of stories for each district
BuildingNumber : Stores the number of buildings depending on building types,
construction material and number of stories for each district
HouseholdData : Stores different parameters describing the household numbers,
household members, and household spaces for each district
DwellingFloorspace : Stores the floorspace per dwelling depending on the building,
dwelling, tenure types and construction material for each
district
DwellingDistribution: Stores the number of dwellings of different sizes depending
on the building, dwelling, tenure types and construction
material for each district
BuildingType : Stores the different types of buildings
DwellingType : Stores the different types of dwellings
TenureType : Stores the different types of tenures
ConstructionMaterial: Stores the construction-material types
StoryNumber : Stores the number (e.g. 1, 2, 3, 4, ...) and classifications
(1-2, 3-5, ...) of numbers of stories.
DwellingSizeType : Stores the different types of dwelling sizes
District : Stores the districts with their IDs, names and geometries
DwellingNumber : Stores the number of dwellings depending on building types,
construction material and number of stories for each
district
BuildingNumber : Stores the number of buildings depending on building types,
construction material and number of stories for each
district
HouseholdData : Stores different parameters describing the household
numbers, household members, and household spaces for each
district
DwellingFloorspace : Stores the floorspace per dwelling depending on the
building, dwelling, tenure types and construction material
for each district
DwellingDistribution : Stores the number of dwellings of different sizes depending
on the building, dwelling, tenure types and construction
material for each district
BuildingType : Stores the different types of buildings
DwellingType : Stores the different types of dwellings
TenureType : Stores the different types of tenures
ConstructionMaterial : Stores the construction-material types
StoryNumber : Stores the number (e.g. 1, 2, 3, 4, ...) and classifications
(1-2, 3-5, ...) of numbers of stories.
DwellingSizeType : Stores the different types of dwelling sizes
BuildingClassesMapping: Stores GEM taxonomy-based building classes
"""
# Create table District
......@@ -238,6 +242,16 @@ class JapanDatabase(SpatialiteDatabase):
self.connection.execute(sql_statement)
logger.debug("Table DwellingSizeType created")
# Create table BuildingClassesMapping
sql_statement = "CREATE TABLE BuildingClassesMapping ("
sql_statement += "id INTEGER PRIMARY KEY, "
sql_statement += "building_type_id INTEGER, "
sql_statement += "construction_material_id INTEGER, "
sql_statement += "story_number_id INTEGER, "
sql_statement += "building_class TEXT)"
self.connection.execute(sql_statement)
logger.debug("Table BuildingClassesMapping created")
def insert_building_type(self, building_type_id, description):
"""
Inserts a building-type description to the BuildingType table.
......@@ -1682,3 +1696,42 @@ class JapanDatabase(SpatialiteDatabase):
logger.info("Dwelling-size types added")
self.connection.commit()
def import_gem_building_class_mapping(self, gem_taxonomy_mapping_file):
"""
Imports the GEM taxonomy-based building classes mapped to the building exposure
attributes.
Args:
gem_taxonomy_mapping_file (str):
Filepath to the file of mapped building exposure attributes to
GEM taxonomy-based building classes
"""
# Read Excel file with building exposure attributes mapped to GEM taxonomy-based
# building classes
gem_taxonomy_mapping = pandas.read_excel(
gem_taxonomy_mapping_file, usecols=[1, 3, 5, 6]
)
for index, row in gem_taxonomy_mapping.iterrows():
building_type_id = row["building_type_id"]
construction_material_id = row["construction_material_id"]
story_number_id = row["story_number_id"]
building_class = row["taxonomy_string"]
# Insert building attributes mapped to their corresponding
# GEM taxonomy-based building classes
sql_statement = (
"INSERT INTO BuildingClassesMapping "
"(building_type_id, construction_material_id, "
"story_number_id, building_class) "
"VALUES (%d, %d, %d, '%s')"
% (building_type_id, construction_material_id, story_number_id, building_class)
)
logger.debug(sql_statement)
self.cursor.execute(sql_statement)
self.connection.commit()
logger.info(
"Imported BuildingClassesMapping table with GEM taxonomy-based building classes"
)
......@@ -50,6 +50,7 @@ def main():
"data/e011_2e.xlsx",
"data/e014e.xlsx",
)
db.import_gem_building_class_mapping("mapping_files/GEM_Tax_Building_class.xlsx")
# Leave the program
sys.exit()
......
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