From e9ac465bd9e6336e1b74e9ed5f271490c85e50bd Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 8 Oct 2024 13:03:42 +0000 Subject: [PATCH 1/4] docs(contributor): contrib-readme-action has updated readme --- README.md | 161 ++++++++++++++++++++++++++---------------------------- 1 file changed, 77 insertions(+), 84 deletions(-) diff --git a/README.md b/README.md index c424dfe34..c28c7cc2e 100644 --- a/README.md +++ b/README.md @@ -191,17 +191,17 @@ The documentation is available here: [documentation](https://pypsa-earth.readthe - - - - + - - - - - + + + + + + + + + - + + + - + + + + - + + +
- - FabianHofmann + + SermishaNarayana
- Fabian Hofmann + Null
- - fneum + + davide-f
- Fabian Neumann + Davide-f
@@ -212,60 +212,39 @@ The documentation is available here: [documentation](https://pypsa-earth.readthe - - euronion + + pz-max
- Euronion + Max Parzen
- - Justus-coded + + DeniseGiub
- Justus Ilemobayo + DeniseGiub
- - mnm-matin + + yerbol-akhmetov
- Mnm-matin + Yerbol Akhmetov
- - martacki -
- Martha Frysztacki -
-
- - LukasFrankenQ -
- Lukas Franken -
-
- - pz-max -
- Max Parzen -
-
- - davide-f + + GbotemiB
- Davide-f + Emmanuel Bolarinwa
- - koen-vg + + mnm-matin
- Koen Van Greevenbroek + Mnm-matin
@@ -274,8 +253,7 @@ The documentation is available here: [documentation](https://pypsa-earth.readthe
Hazem -
energyLS @@ -283,48 +261,27 @@ The documentation is available here: [documentation](https://pypsa-earth.readthe EnergyLS - - AnasAlgarei -
- AnasAlgarei -
-
- - yerbol-akhmetov -
- Yerbol Akhmetov -
-
- - DeniseGiub -
- DeniseGiub -
-
- - GbotemiB -
- Emmanuel Bolarinwa -
-
Tomkourou
Thomas Kouroughli
-
GridGrapher
GridGrapher
+
+ + martacki +
+ Martha Frysztacki +
@@ -369,6 +326,27 @@ The documentation is available here: [documentation](https://pypsa-earth.readthe Cschau + + euronion +
+ Euronion +
+
+ + AnasAlgarei +
+ AnasAlgarei +
+
+ + LukasFrankenQ +
+ Lukas Franken +
+
Tooblippe @@ -382,7 +360,8 @@ The documentation is available here: [documentation](https://pypsa-earth.readthe
Anton Achhammer
-
asolavi @@ -390,6 +369,13 @@ The documentation is available here: [documentation](https://pypsa-earth.readthe Null + + koen-vg +
+ Koen Van Greevenbroek +
+
carlosfv92 @@ -403,8 +389,7 @@ The documentation is available here: [documentation](https://pypsa-earth.readthe
Stephen J Lee
-
rsparks3 @@ -418,7 +403,8 @@ The documentation is available here: [documentation](https://pypsa-earth.readthe
Null
-
juli-a-ko @@ -446,8 +432,7 @@ The documentation is available here: [documentation](https://pypsa-earth.readthe
Pietro Monticone
-
Netotse @@ -461,7 +446,8 @@ The documentation is available here: [documentation](https://pypsa-earth.readthe
Katherine M. Antonio
-
jessLryan @@ -483,21 +469,28 @@ The documentation is available here: [documentation](https://pypsa-earth.readthe HanaElattar + + FabianHofmann +
+ Fabian Hofmann +
+
EmreYorat
EmreYorat
-
AndreCNF
André Cristóvão Neves Ferreira
-
AlexanderMeisinger From e85f01d18ebf7271cd862fb8fc5be41234f57c0b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 16 Oct 2024 08:42:52 +0000 Subject: [PATCH 2/4] docs(contributor): contrib-readme-action has updated readme --- README.md | 161 ++++++++++++++++++++++++++---------------------------- 1 file changed, 77 insertions(+), 84 deletions(-) diff --git a/README.md b/README.md index c424dfe34..c28c7cc2e 100644 --- a/README.md +++ b/README.md @@ -191,17 +191,17 @@ The documentation is available here: [documentation](https://pypsa-earth.readthe - - - - + - - - - - + + + + + + + + + - + + + - + + + + - + + +
- - FabianHofmann + + SermishaNarayana
- Fabian Hofmann + Null
- - fneum + + davide-f
- Fabian Neumann + Davide-f
@@ -212,60 +212,39 @@ The documentation is available here: [documentation](https://pypsa-earth.readthe - - euronion + + pz-max
- Euronion + Max Parzen
- - Justus-coded + + DeniseGiub
- Justus Ilemobayo + DeniseGiub
- - mnm-matin + + yerbol-akhmetov
- Mnm-matin + Yerbol Akhmetov
- - martacki -
- Martha Frysztacki -
-
- - LukasFrankenQ -
- Lukas Franken -
-
- - pz-max -
- Max Parzen -
-
- - davide-f + + GbotemiB
- Davide-f + Emmanuel Bolarinwa
- - koen-vg + + mnm-matin
- Koen Van Greevenbroek + Mnm-matin
@@ -274,8 +253,7 @@ The documentation is available here: [documentation](https://pypsa-earth.readthe
Hazem -
energyLS @@ -283,48 +261,27 @@ The documentation is available here: [documentation](https://pypsa-earth.readthe EnergyLS - - AnasAlgarei -
- AnasAlgarei -
-
- - yerbol-akhmetov -
- Yerbol Akhmetov -
-
- - DeniseGiub -
- DeniseGiub -
-
- - GbotemiB -
- Emmanuel Bolarinwa -
-
Tomkourou
Thomas Kouroughli
-
GridGrapher
GridGrapher
+
+ + martacki +
+ Martha Frysztacki +
@@ -369,6 +326,27 @@ The documentation is available here: [documentation](https://pypsa-earth.readthe Cschau + + euronion +
+ Euronion +
+
+ + AnasAlgarei +
+ AnasAlgarei +
+
+ + LukasFrankenQ +
+ Lukas Franken +
+
Tooblippe @@ -382,7 +360,8 @@ The documentation is available here: [documentation](https://pypsa-earth.readthe
Anton Achhammer
-
asolavi @@ -390,6 +369,13 @@ The documentation is available here: [documentation](https://pypsa-earth.readthe Null + + koen-vg +
+ Koen Van Greevenbroek +
+
carlosfv92 @@ -403,8 +389,7 @@ The documentation is available here: [documentation](https://pypsa-earth.readthe
Stephen J Lee
-
rsparks3 @@ -418,7 +403,8 @@ The documentation is available here: [documentation](https://pypsa-earth.readthe
Null
-
juli-a-ko @@ -446,8 +432,7 @@ The documentation is available here: [documentation](https://pypsa-earth.readthe
Pietro Monticone
-
Netotse @@ -461,7 +446,8 @@ The documentation is available here: [documentation](https://pypsa-earth.readthe
Katherine M. Antonio
-
jessLryan @@ -483,21 +469,28 @@ The documentation is available here: [documentation](https://pypsa-earth.readthe HanaElattar + + FabianHofmann +
+ Fabian Hofmann +
+
EmreYorat
EmreYorat
-
AndreCNF
André Cristóvão Neves Ferreira
-
AlexanderMeisinger From 9ed41891fa3b5d16fbd486f6932c731f4c91d521 Mon Sep 17 00:00:00 2001 From: Sermisha Date: Wed, 16 Oct 2024 14:13:50 +0530 Subject: [PATCH 3/4] feature: Feature to add a tolerance value to simplify GADM shapes --- config.default.yaml | 1 + doc/configtables/build_shape_options.csv | 19 ++++++++++--------- scripts/build_shapes.py | 13 +++++++++---- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/config.default.yaml b/config.default.yaml index 431812b94..344b5aa93 100644 --- a/config.default.yaml +++ b/config.default.yaml @@ -106,6 +106,7 @@ cluster_options: build_shape_options: gadm_layer_id: 1 # GADM level area used for the gadm_shapes. Codes are country-dependent but roughly: 0: country, 1: region/county-like, 2: municipality-like + simplify_tolerance: 0.01 # Default value is 0.01, higher the value more is the simplification of the GADM shapes update_file: false # When true, all the input files are downloaded again and replace the existing files out_logging: true # When true, logging is printed to console year: 2020 # reference year used to derive shapes, info on population and info on GDP diff --git a/doc/configtables/build_shape_options.csv b/doc/configtables/build_shape_options.csv index 78df78713..678bbfc4d 100644 --- a/doc/configtables/build_shape_options.csv +++ b/doc/configtables/build_shape_options.csv @@ -1,9 +1,10 @@ -,Unit,Values,Description -gadm_layer_id,, "{0, 1, 2}", "GADM level area used for the gadm_shapes. Codes are country-dependent but roughly: 0: country, 1: region/county-like, 2: municipality-like." -update_file, bool, "{True, False}", "True: all input files are downloaded again and replace the existing files." -out_logging, bool, "{True, False}", "True: Logging is printed in the console." -year,, "past year; e.g. YYYY", "Reference year used to derive shapes, info on population and info on GDP." -nprocesses, int,, "Number of processes to be used in build_shapes." -worldpop_method,, "{""standard"", ""api"", false}", "Specifies how population is added to every shape: ""standard"" pulls from web 1kmx1km raster; ""api"" pulls from API 100mx100m raster; false (not ""false"") no population addition to shape. This is useful when generating only cutout." -gdp_method,, "{""standard"", false}", "Specifies how GDP is added to every shape: ""standard"" pulls from web 1x1km raster; false (not ""false"") no gdp addition to shape. This is useful when generating only cutout." -contended_flag,, "{""set_by_country"", ""drop""}", "Specifies what to do with contended countries: ""set_by_country"" assigns the contended areas to the countries according to the GADM database; ""drop"" drops the contended areas from the model." +,Unit,Values,Description,,,, +gadm_layer_id,,"""{0",1,"2}""","""GADM level area used for the gadm_shapes. Codes are country-dependent but roughly: 0: country",1: region/county-like,"2: municipality-like.""" +simplify_tolerance,float,>= 0,Specifies tolerance limit when simplifying GADM shapes. A higher value indicates more simplification,,,, +update_file, bool," ""{True"," False}"""," ""True: all input files are downloaded again and replace the existing files.""",,, +out_logging, bool," ""{True"," False}"""," ""True: Logging is printed in the console.""",,, +year,," ""past year; e.g. YYYY"""," ""Reference year used to derive shapes"," info on population and info on GDP.""",,, +nprocesses, int,," ""Number of processes to be used in build_shapes.""",,,, +worldpop_method,," ""{""standard"""," ""api"""," false}""","""Specifies how population is added to every shape: ""standard"" pulls from web 1kmx1km raster; ""api"" pulls from API 100mx100m raster; false (not ""false"") no population addition to shape. This is useful when generating only cutout.""",, +gdp_method,," ""{""standard"""," false}""","""Specifies how GDP is added to every shape: ""standard"" pulls from web 1x1km raster; false (not ""false"") no gdp addition to shape. This is useful when generating only cutout.""",,, +contended_flag,," ""{""set_by_country"""," ""drop""}"""," ""Specifies what to do with contended countries: ""set_by_country"" assigns the contended areas to the countries according to the GADM database; ""drop"" drops the contended areas from the model.""",,, \ No newline at end of file diff --git a/scripts/build_shapes.py b/scripts/build_shapes.py index 22e6b68cf..7e4bbb849 100644 --- a/scripts/build_shapes.py +++ b/scripts/build_shapes.py @@ -261,7 +261,7 @@ def _simplify_polys(polys, minarea=0.01, tolerance=0.01, filterremote=False): return polys.simplify(tolerance=tolerance) -def countries(countries, geo_crs, contended_flag, update=False, out_logging=False): +def countries(countries, geo_crs, contended_flag, update=False, out_logging=False, tolerance=0.01): "Create country shapes" if out_logging: @@ -282,7 +282,8 @@ def countries(countries, geo_crs, contended_flag, update=False, out_logging=Fals df_countries.rename(columns={"GID_0": "name"}, inplace=True) # set index and simplify polygons - ret_df = df_countries.set_index("name")["geometry"].map(_simplify_polys) + ret_df = df_countries.set_index("name")["geometry"].map(lambda x: _simplify_polys(x,tolerance=tolerance)) + # there may be "holes" in the countries geometry which cause troubles along the workflow # e.g. that is the case for enclaves like Dahagram–Angarpota for IN/BD ret_df = ret_df.make_valid() @@ -1256,6 +1257,7 @@ def gadm( out_logging=False, year=2020, nprocesses=None, + tolerance=0.01, ): if out_logging: logger.info("Stage 3 of 5: Creation GADM GeoDataFrame") @@ -1305,7 +1307,7 @@ def gadm( lambda x: x if x.find(".") == 0 else "." + x ) df_gadm.set_index("GADM_ID", inplace=True) - df_gadm["geometry"] = df_gadm["geometry"].map(_simplify_polys) + df_gadm["geometry"] = df_gadm["geometry"].map(lambda x: _simplify_polys(x,tolerance=tolerance)) df_gadm.geometry = df_gadm.geometry.apply( lambda r: make_valid(r) if not r.is_valid else r ) @@ -1338,6 +1340,7 @@ def gadm( contended_flag = snakemake.params.build_shape_options["contended_flag"] worldpop_method = snakemake.params.build_shape_options["worldpop_method"] gdp_method = snakemake.params.build_shape_options["gdp_method"] + tolerance = snakemake.params.build_shape_options['simplify_tolerance'] country_shapes = countries( countries_list, @@ -1345,11 +1348,12 @@ def gadm( contended_flag, update, out_logging, + tolerance=tolerance, ) country_shapes.to_file(snakemake.output.country_shapes) offshore_shapes = eez( - countries_list, geo_crs, country_shapes, EEZ_gpkg, out_logging + countries_list, geo_crs, country_shapes, EEZ_gpkg, out_logging, tolerance=tolerance ) offshore_shapes.reset_index().to_file(snakemake.output.offshore_shapes) @@ -1371,5 +1375,6 @@ def gadm( out_logging, year, nprocesses=nprocesses, + tolerance=tolerance, ) save_to_geojson(gadm_shapes, out.gadm_shapes) From 72a5913e781058f8211513830087218502b1a4bd Mon Sep 17 00:00:00 2001 From: Sermisha Date: Thu, 17 Oct 2024 19:14:03 +0530 Subject: [PATCH 4/4] doc: Release note update --- doc/release_notes.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/release_notes.rst b/doc/release_notes.rst index 470e9743d..7d1f8dbbb 100644 --- a/doc/release_notes.rst +++ b/doc/release_notes.rst @@ -28,6 +28,8 @@ E.g. if a new rule becomes available describe how to use it `make test` and in o * Fix the mismatch between buses and x, y locations while creating H2 Stores `PR #1134 `_ +* Included a configuration option to quantitavely set the tolerance levels for simplifying GADM shapes `PR #1147 ` + PyPSA-Earth 0.4.1 =================