diff --git a/gis/population/population/space.py b/gis/population/population/space.py index 6dce4b2c..3549d9be 100644 --- a/gis/population/population/space.py +++ b/gis/population/population/space.py @@ -1,5 +1,6 @@ from __future__ import annotations +import gzip import uuid import geopandas as gpd @@ -36,9 +37,10 @@ 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, cell_cls=UgandaCell, attr_name="population", + rio_opener=gzip.open, ) raster_layer.crs = world_size.crs raster_layer.total_bounds = world_size.total_bounds diff --git a/gis/rainfall/rainfall/space.py b/gis/rainfall/rainfall/space.py index 77e9dccd..87b35380 100644 --- a/gis/rainfall/rainfall/space.py +++ b/gis/rainfall/rainfall/space.py @@ -1,5 +1,7 @@ from __future__ import annotations +import gzip + import mesa import mesa_geo as mg import numpy as np @@ -34,9 +36,10 @@ 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, cell_cls=LakeCell, attr_name="elevation", + rio_opener=gzip.open, ) raster_layer.crs = crs raster_layer.apply_raster( diff --git a/gis/urban_growth/urban_growth/space.py b/gis/urban_growth/urban_growth/space.py index ee065e6b..7e132d79 100644 --- a/gis/urban_growth/urban_growth/space.py +++ b/gis/urban_growth/urban_growth/space.py @@ -1,5 +1,6 @@ from __future__ import annotations +import gzip import random import mesa @@ -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)