6. Examples

6.1. Example 1: Modules

The following is an example showing how to call pretrained models to predict on images.

You can run this example on your computer or in this notebook on Google Colab.

The images used in the example can be downloaded from here: image_examples.zip.

# import modules
from brails.modules import RoofClassifier, OccupancyClassifier, SoftstoryClassifier

# initilize a roof classifier
roofModel = RoofClassifier()

# initilize an occupancy classifier
occupancyModel = OccupancyClassifier()

# initilize a soft-story classifier
ssModel = SoftstoryClassifier()

# use the roof classifier

imgs = ['image_examples/Roof/gabled/76.png',
        'image_examples/Roof/hipped/54.png',
        'image_examples/Roof/flat/94.png']

predictions = roofModel.predict(imgs)

# use the occupancy classifier

imgs = ['image_examples/Occupancy/RES1/51563.png',
        'image_examples/Occupancy/RES3/65883.png']

predictions = occupancyModel.predict(imgs)

# use the softstory classifier

imgs = ['image_examples/Softstory/Others/3110.jpg',
        'image_examples/Softstory/Softstory/901.jpg']

predictions = ssModel.predict(imgs)

6.2. Example 2: Workflow

The following is an example showing how to create a building inventory for a city.

You can run this example on your computer or in this notebook on Google Colab.

You need to provide the Google maps API key for downloading street view and satellite images.

Instructions on obtaining the API key can be found here: https://developers.google.com/maps/documentation/embed/get-api-key.

Use should limit the number of buildings (numBldg) because of this.

from brails.CityBuilder import CityBuilder

cityBuilder = CityBuilder(attributes=['occupancy','roofshape'],
               numBldg=1000,random=False, place='Lake Charles, LA',
               GoogleMapAPIKey='put-your-API-key-here',
               overwrite=True)

BIM = cityBuilder.build()
attributes (list)

A list of building attributes, such as [‘story’, ‘occupancy’, ‘roofshape’], which are available in the current version.

numBldg (int)

Number of buildings to generate.

random (bool)

Randomly select numBldg buildings from the database if random is True.

place (str)

The region of interest, e.g., Berkeley, California.

GoogleMapAPIKey (str)

Google API Key.

overwrite (bool)

Overwrite existing tmp files. Default value is False.

../../_images/Berkeley.png

Fig. 6.2.1 Generated Buildings

Table 6.2.1 Generated BIM File

geometry

ID

softStory

softStoryProb

occupancy

occupancyProb

roofShape

roofShapeProb

POLYGON ((-122.28425 37.893205, -122.284283 37.893193, -122.284229 37.893098, -122.284111 37.893141, -122.284184 37.893267, -122.284268 37.893236, -122.28425 37.893205))

0

others

0.884251654

RES1

0.997940361

hipped

0.901893497

POLYGON ((-122.281309 37.893283, -122.281408 37.893416, -122.281502 37.893373, -122.281403 37.89324, -122.281309 37.893283))

1

softstory

0.818908155

RES3

0.999334514

hipped

0.99905473

POLYGON ((-122.28172 37.893669, -122.281687 37.893564, -122.281566 37.893588, -122.2816 37.893693, -122.28172 37.893669))

2

softstory

0.964413881

RES3

0.949093223

hipped

0.986970901

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

6.3. Example 3: Workflow

The following is an example showing how to create a building inventory for a region defined using a bounding box.

You can run this example on your computer or in this notebook on Google Colab.

You need to provide the Google maps API key for downloading street view and satellite images.

Instructions on obtaining the API key can be found here: https://developers.google.com/maps/documentation/embed/get-api-key.

Use should limit the number of buildings (numBldg) because of this.

from brails.CityBuilder import CityBuilder

cityBuilder = CityBuilder(attributes=['softstory','occupancy','roofshape'],
               numBldg=100,random=False, bbox=[37.872187, -122.282178,37.870629, -122.279765],
               GoogleMapAPIKey='put-your-API-key-here',
               overwrite=True)

BIM = cityBuilder.build()
attributes (list)

A list of building attributes, such as [‘story’, ‘occupancy’, ‘roofshape’], which are available in the current version.

numBldg (int)

Number of buildings to generate.

random (bool)

Randomly select numBldg buildings from the database if random is True.

bbox (list)

[north, west, south, east], which defines a region of interest.

GoogleMapAPIKey (str)

Google API Key.

overwrite (bool)

Overwrite existing tmp files. Default value is False.

../../_images/Christchurch.png

Fig. 6.3.1 Generated Buildings

Table 6.3.1 Generated BIM File

geometry

ID

softStory

softStoryProb

occupancy

occupancyProb

roofShape

roofShapeProb

POLYGON ((172.6511771 -43.5284542, 172.6511784 -43.5283969, 172.6512398 -43.5283977, 172.6512385 -43.5284549, 172.6511771 -43.5284542))

0

others

0.999716461

RES1

0.999994993

gabled

0.549040675

POLYGON ((172.6526413 -43.5280566, 172.6524643 -43.5280545, 172.6524647 -43.5280356, 172.6524423 -43.5280354, 172.6524436 -43.527975, 172.6524959 -43.5279757, 172.6524954 -43.527996, 172.6525252 -43.5279964, 172.6525256 -43.527976, 172.6526431 -43.5279774, 172.6526413 -43.5280566))

1

others

0.997607112

RES1

0.999310851

gabled

0.529587984

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.