Skip to content

Commit

Permalink
gis: Pass model to RasterLayer.from_file (projectmesa#186)
Browse files Browse the repository at this point in the history
Fixes the population and rainfall models by passing model to RasterLayer.from_file().

> The RasterLayer creates Cells, Cells inherit from Agents, Agents need model input, but RasterLayer doesn't have access to model.
  • Loading branch information
EwoutH committed Sep 20, 2024
1 parent 8aea8fc commit 1e864f3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions gis/population/population/space.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def load_data(self, population_gzip_file, lake_zip_file, world_zip_file, model):
world_size = gpd.GeoDataFrame.from_file(world_zip_file)
raster_layer = RasterLayer.from_file(
population_gzip_file,
model=model,
cell_cls=UgandaCell,
attr_name="population",
rio_opener=gzip.open,
Expand Down
1 change: 1 addition & 0 deletions gis/rainfall/rainfall/space.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def __init__(self, crs, water_height, model):
def set_elevation_layer(self, elevation_gzip_file, crs):
raster_layer = mg.RasterLayer.from_file(
elevation_gzip_file,
model=self.model,
cell_cls=LakeCell,
attr_name="elevation",
rio_opener=gzip.open,
Expand Down

0 comments on commit 1e864f3

Please sign in to comment.