-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement loading ventilation index zones
- Loading branch information
Showing
2 changed files
with
25 additions
and
3 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |