Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add model parameter in RasterLayer class method #240

Merged
merged 1 commit into from
Sep 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 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 @@
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)

Check warning on line 563 in mesa_geo/raster_layers.py

View check run for this annotation

Codecov / codecov/patch

mesa_geo/raster_layers.py#L563

Added line #L563 was not covered by tests
obj._transform = dataset.transform
obj.apply_raster(values, attr_name=attr_name)
return obj
Expand Down