Skip to content

Commit

Permalink
Add model parameter in RasterLayer class method (#240)
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-boyu authored Sep 2, 2024
1 parent fc4028b commit 5fb2dde
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion mesa_geo/raster_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import numpy as np
import rasterio as rio
from affine import Affine
from mesa import Model
from mesa.agent import Agent
from mesa.space import Coordinate, accept_tuple_argument
from rasterio.warp import (
Expand Down Expand Up @@ -535,6 +536,7 @@ def to_image(self, colormap) -> ImageLayer:
def from_file(
cls,
raster_file: str,
model: Model,
cell_cls: type[Cell] = Cell,
attr_name: str | None = None,
rio_opener: Callable | None = None,
Expand All @@ -558,7 +560,7 @@ def from_file(
dataset.bounds.right,
dataset.bounds.top,
]
obj = cls(width, height, dataset.crs, total_bounds, cell_cls)
obj = cls(width, height, dataset.crs, total_bounds, model, cell_cls)
obj._transform = dataset.transform
obj.apply_raster(values, attr_name=attr_name)
return obj
Expand Down

0 comments on commit 5fb2dde

Please sign in to comment.