Skip to content

Commit

Permalink
Merge branch 'main' into gis_model_passing
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-boyu authored Sep 2, 2024
2 parents 5b2a733 + dee6363 commit 9f91312
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion gis/population/population/space.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import gzip
import uuid

import geopandas as gpd
Expand Down Expand Up @@ -36,10 +37,11 @@ def __init__(self, crs):
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(
f"/vsigzip/{population_gzip_file}",
population_gzip_file,
model=model,
cell_cls=UgandaCell,
attr_name="population",
rio_opener=gzip.open,
)
raster_layer.crs = world_size.crs
raster_layer.total_bounds = world_size.total_bounds
Expand Down
5 changes: 4 additions & 1 deletion gis/rainfall/rainfall/space.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from __future__ import annotations

import gzip

import mesa
import mesa_geo as mg
import numpy as np
Expand Down Expand Up @@ -34,10 +36,11 @@ def __init__(self, crs, water_height, model):

def set_elevation_layer(self, elevation_gzip_file, crs):
raster_layer = mg.RasterLayer.from_file(
f"/vsigzip/{elevation_gzip_file}",
elevation_gzip_file,
model=self.model,
cell_cls=LakeCell,
attr_name="elevation",
rio_opener=gzip.open,
)
raster_layer.crs = crs
raster_layer.apply_raster(
Expand Down
3 changes: 2 additions & 1 deletion gis/urban_growth/urban_growth/space.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import gzip
import random

import mesa
Expand Down Expand Up @@ -96,7 +97,7 @@ def load_datasets(
"land_use": land_use_data,
}
for attribute_name, data_file in data.items():
with rio.open(f"/vsigzip/{data_file}", "r") as dataset:
with rio.open(data_file, "r", opener=gzip.open) as dataset:
values = dataset.read()
self.raster_layer.apply_raster(values, attr_name=attribute_name)

Expand Down

0 comments on commit 9f91312

Please sign in to comment.