Skip to content

Commit

Permalink
Implement loading ventilation index zones
Browse files Browse the repository at this point in the history
  • Loading branch information
bolny committed Dec 12, 2024
1 parent 899d857 commit 9b0c8c9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
Binary file added data/ventilation_index_zones.geojson.xz
Binary file not shown.
28 changes: 25 additions & 3 deletions utils/zones.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,33 @@
import lzma

from geopandas import read_file, GeoDataFrame

COMPRESSED_FILEPATH = "./data/ventilation_index_zones.geojson.xz"
DECOMPRESSED_FILEPATH = "./tmp/ventilation_index_zones.geojson"


def _compress_ventilation_index_zones():
# Git has a filesize limit of 50MB. The shapefile is 60MB, so it should be
# compressed at rest.
with open(DECOMPRESSED_FILEPATH, "rb") as f_in:
bytes = f_in.read()
with lzma.open(COMPRESSED_FILEPATH, "w") as f_out:
f_out.write(bytes)


def _decompress_ventilation_index_zones():
with lzma.open(COMPRESSED_FILEPATH, "r") as f_in:
bytes = f_in.read()
with open(DECOMPRESSED_FILEPATH, "wb") as f_out:
f_out.write(bytes)


def get_ventilation_index_zones() -> GeoDataFrame:
ventilation_index_zones: GeoDataFrame = read_file("./data/ventilation_index_zones.geojson")
def read_ventilation_index_zones() -> GeoDataFrame:
_decompress_ventilation_index_zones()
ventilation_index_zones = read_file(DECOMPRESSED_FILEPATH)
print(f"loaded {ventilation_index_zones.shape[0]} ventilation index zones.")
return ventilation_index_zones


if __name__ == "__main__":
get_ventilation_index_zones()
read_ventilation_index_zones()

0 comments on commit 9b0c8c9

Please sign in to comment.