Complete CSV (Excel File) #369
Unanswered
AbdJamali202
asked this question in
Brails++
Replies: 2 comments 3 replies
-
|
Yes! Here's a Python script using BRAILS that generates a CSV with those columns. Note that Fragility Number is not a native BRAILS output, so it needs to be derived in post-processing based on occupancy and number of stories. A few things to keep in mind:
|
Beta Was this translation helpful? Give feedback.
1 reply
-
|
Thank you for your detailed explanation. My project is based in Canada rather than the United States, so I understand that fpSource='usastr' and baselineInv='nsi' may not be suitable, given that usastr corresponds to FEMA USA Structures and NSI is maintained by the U.S. Army Corps of Engineers for U.S.-specific building inventories.
In this context, would you recommend using fpSource='osm', fpSource='ms', or a user-provided GeoJSON as the most appropriate option for a Canadian study area?
Additionally, is a Google API key strictly required when using InventoryGenerator.generate() to predict attributes such as numstories and occupancy? If so, could you please clarify where it should be created and which services need to be enabled?
Finally, I would appreciate any guidance or example of a workflow adapted to a Canadian context.
Best regards,
…________________________________
De : RJ Edwards ***@***.***>
Envoyé : dimanche 29 mars 2026 00:10
À : NHERI-SimCenter/SimCenterCommon ***@***.***>
Cc : AbdJamali202 ***@***.***>; Author ***@***.***>
Objet : Re: [NHERI-SimCenter/SimCenterCommon] Complete CSV (Excel File) (Discussion #369)
Yes! Here's a Python script using BRAILS that generates a CSV with those columns. Note that Fragility Number is not a native BRAILS output, so it needs to be derived in post-processing based on occupancy and number of stories.
from brails.InventoryGenerator import InventoryGenerator
# Initialize and generate inventory
invGenerator = InventoryGenerator(
location='San Rafael, CA',
fpSource='usastr', # Provides Geometry + coordinates
baselineInv='nsi', # Provides Basement + Occupancy baseline
lengthUnit='m'
)
invGenerator.generate(
attributes=['numstories', 'occupancy'],
GoogleAPIKey='YOUR_GOOGLE_API_KEY'
)
df = invGenerator.inventory
# Rename columns to match desired schema
df = df.rename(columns={
'lat': 'Latitude',
'lon': 'Longitude',
'numstories': 'NumberOfStories',
'geometry': 'Geometry',
'basement': 'Basement',
'occupancy': 'Occupancy'
})
# Derive Fragility Number (customize to your fragility taxonomy)
def assign_fragility(row):
occ = str(row.get('Occupancy', '')).upper()
stories = row.get('NumberOfStories', 1)
if 'RES' in occ and stories <= 2:
return 'W1'
elif 'RES' in occ and stories > 2:
return 'C1M'
elif 'COM' in occ:
return 'S1L'
else:
return 'UNK'
df['FragilityNumber'] = df.apply(assign_fragility, axis=1)
# Export to CSV
cols = ['Latitude', 'Longitude', 'NumberOfStories', 'Geometry', 'Basement', 'Occupancy', 'FragilityNumber']
df[cols].to_csv('building_inventory.csv', index=False)
A few things to keep in mind:
* fpSource='usastr' (FEMA USA Structures) gives you the building footprint geometry and coordinates.
* baselineInv='nsi' pulls basement and occupancy data from the National Structure Inventory.
* The assign_fragility function above is a simplified example, so swap in whatever fragility classification scheme (HAZUS, FEMA P-58, etc.) your project requires.
* A Google API Key is needed for imagery-based predictions like numstories and occupancy.
—
Reply to this email directly, view it on GitHub<#369?email_source=notifications&email_token=BVBRFROI36Y4MQ7B4KSFVMD4TBLXZA5CNFSNUABIM5UWIORPF5TWS5BNNB2WEL2ENFZWG5LTONUW63SDN5WW2ZLOOQXTCNRTGYYTAMJQUZZGKYLTN5XKMYLVORUG64VFMV3GK3TUVRTG633UMVZF6Y3MNFRWW#discussioncomment-16361010>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/BVBRFRNBCHBG642W6OD322D4TBLXZAVCNFSM6AAAAACXDRQT4CVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTMMZWGEYDCMA>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Thank you in advance for your assistance. Is there a Python code using BRAILS that can directly generate a CSV file containing the following columns: Latitude, Longitude, NumberOfStories, Geometry, basement, Occupancy, and Fragility Number?
Beta Was this translation helpful? Give feedback.
All reactions