Skip to content

Commit 88acb83

Browse files
euronionlkstrp
andauthored
code: Fix logic for extracting WDPA and WDPA marine (#2010)
* code: Fix logic for extracting bYYYY from filename * doc: Add release notes --------- Co-authored-by: Lukas Trippe <lkstrp@pm.me>
1 parent 3f04d24 commit 88acb83

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

doc/release_notes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ Upcoming Release
170170

171171
* Misc: Automatically update the DAGs shown in the documentation (https://github.com/PyPSA/pypsa-eur/pull/1880).
172172

173+
* Fix: An issue with the download and extraction of WDPA and WDPA Marine data (https://github.com/PyPSA/pypsa-eur/issues/2005).
174+
173175
PyPSA-Eur v2025.07.0 (11th July 2025)
174176
=====================================
175177

rules/retrieve.smk

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,6 +858,12 @@ if (WDPA_DATASET := dataset_version("wdpa"))["source"] in [
858858
copy2(input["zip_file"], output["zip_file"])
859859
unpack_archive(output["zip_file"], output_folder)
860860

861+
# Extract {bYYYY} from the input file / URL
862+
bYYYY = re.search(
863+
r"WDPA_(\w{3}\d{4})_Public_shp.zip",
864+
input["zip_file"],
865+
).group(1)
866+
861867
for i in range(3):
862868
# vsizip is special driver for directly working with zipped shapefiles in ogr2ogr
863869
layer_path = (
@@ -889,6 +895,12 @@ if (WDPA_MARINE_DATASET := dataset_version("wdpa_marine"))["source"] in [
889895
copy2(input["zip_file"], output["zip_file"])
890896
unpack_archive(output["zip_file"], output_folder)
891897

898+
# Extract {bYYYY} from the input file / URL
899+
bYYYY = re.search(
900+
r"WDPA_WDOECM_(\w{3}\d{4})_Public_marine_shp.zip",
901+
input["zip_file"],
902+
).group(1)
903+
892904
for i in range(3):
893905
# vsizip is special driver for directly working with zipped shapefiles in ogr2ogr
894906
layer_path = f"/vsizip/{output_folder}/WDPA_WDOECM_{bYYYY}_Public_marine_shp_{i}.zip"

0 commit comments

Comments
 (0)