From 5fb2dde5e63bbfea10775af988848dbfde4ce8a2 Mon Sep 17 00:00:00 2001 From: Wang Boyu Date: Mon, 2 Sep 2024 07:03:18 -0400 Subject: [PATCH] Add model parameter in RasterLayer class method (#240) --- mesa_geo/raster_layers.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mesa_geo/raster_layers.py b/mesa_geo/raster_layers.py index a39c7b15..3de9fcdd 100644 --- a/mesa_geo/raster_layers.py +++ b/mesa_geo/raster_layers.py @@ -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 ( @@ -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, @@ -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