Skip to content

Commit

Permalink
Fix notebook EPSG error (#332)
Browse files Browse the repository at this point in the history
* fix bug. epsg 3763 to 3857

* add release note

Reviewed: Davide
  • Loading branch information
pz-max authored May 4, 2022
1 parent 39d0ec5 commit 0c8c8c2
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 111 deletions.
128 changes: 32 additions & 96 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,38 +116,31 @@ The documentation is available here: [documentation](https://pypsa-meets-africa.
<table>
<tr>
<td align="center">
<a href="https://github.com/hazemakhalek">
<img src="https://avatars.githubusercontent.com/u/26235356?v=4" width="100;" alt="hazemakhalek"/>
<br />
<sub><b>Hazemakhalek</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/jarry7">
<img src="https://avatars.githubusercontent.com/u/27745389?v=4" width="100;" alt="jarry7"/>
<a href="https://github.com/pz-max">
<img src="https://avatars.githubusercontent.com/u/61968949?v=4" width="100;" alt="pz-max"/>
<br />
<sub><b>Jarrad Wright</b></sub>
<sub><b>Max Parzen</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/fneum">
<img src="https://avatars.githubusercontent.com/u/29101152?v=4" width="100;" alt="fneum"/>
<a href="https://github.com/davide-f">
<img src="https://avatars.githubusercontent.com/u/67809479?v=4" width="100;" alt="davide-f"/>
<br />
<sub><b>Fabian Neumann</b></sub>
<sub><b>Davide-f</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/euronion">
<img src="https://avatars.githubusercontent.com/u/42553970?v=4" width="100;" alt="euronion"/>
<a href="https://github.com/restyled-commits">
<img src="https://avatars.githubusercontent.com/u/65077583?v=4" width="100;" alt="restyled-commits"/>
<br />
<sub><b>Euronion</b></sub>
<sub><b>Restyled Commits</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/Justus-coded">
<img src="https://avatars.githubusercontent.com/u/44394641?v=4" width="100;" alt="Justus-coded"/>
<a href="https://github.com/ekatef">
<img src="https://avatars.githubusercontent.com/u/30229437?v=4" width="100;" alt="ekatef"/>
<br />
<sub><b>Justus Ilemobayo</b></sub>
<sub><b>Ekaterina</b></sub>
</a>
</td>
<td align="center">
Expand All @@ -156,56 +149,41 @@ The documentation is available here: [documentation](https://pypsa-meets-africa.
<br />
<sub><b>Mnm-matin</b></sub>
</a>
</td></tr>
<tr>
<td align="center">
<a href="https://github.com/desenk">
<img src="https://avatars.githubusercontent.com/u/48335263?v=4" width="100;" alt="desenk"/>
<br />
<sub><b>Desen Kirli</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/LukasFrankenQ">
<img src="https://avatars.githubusercontent.com/u/55196140?v=4" width="100;" alt="LukasFrankenQ"/>
<a href="https://github.com/Hazem-IEG">
<img src="https://avatars.githubusercontent.com/u/87850910?v=4" width="100;" alt="Hazem-IEG"/>
<br />
<sub><b>Lukas Franken</b></sub>
<sub><b>Hazem-IEG</b></sub>
</a>
</td>
</td></tr>
<tr>
<td align="center">
<a href="https://github.com/pz-max">
<img src="https://avatars.githubusercontent.com/u/61968949?v=4" width="100;" alt="pz-max"/>
<a href="https://github.com/euronion">
<img src="https://avatars.githubusercontent.com/u/42553970?v=4" width="100;" alt="euronion"/>
<br />
<sub><b>Max Parzen</b></sub>
<sub><b>Euronion</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/Cesare-Caputo">
<img src="https://avatars.githubusercontent.com/u/62548290?v=4" width="100;" alt="Cesare-Caputo"/>
<a href="https://github.com/giacfalk">
<img src="https://avatars.githubusercontent.com/u/36954873?v=4" width="100;" alt="giacfalk"/>
<br />
<sub><b>Cesare-Caputo</b></sub>
<sub><b>Giacomo Falchetta</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/Nayara2020">
<img src="https://avatars.githubusercontent.com/u/64689686?v=4" width="100;" alt="Nayara2020"/>
<a href="https://github.com/LukasFrankenQ">
<img src="https://avatars.githubusercontent.com/u/55196140?v=4" width="100;" alt="LukasFrankenQ"/>
<br />
<sub><b>Nayara2020</b></sub>
<sub><b>Lukas Franken</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/Ay-Khi">
<img src="https://avatars.githubusercontent.com/u/65019030?v=4" width="100;" alt="Ay-Khi"/>
<br />
<sub><b>Ayman Alkhirbash</b></sub>
</a>
</td></tr>
<tr>
<td align="center">
<a href="https://github.com/davide-f">
<img src="https://avatars.githubusercontent.com/u/67809479?v=4" width="100;" alt="davide-f"/>
<a href="https://github.com/Tooblippe">
<img src="https://avatars.githubusercontent.com/u/805313?v=4" width="100;" alt="Tooblippe"/>
<br />
<sub><b>Davide-f</b></sub>
<sub><b>Jarrad Wright</b></sub>
</a>
</td>
<td align="center">
Expand All @@ -216,62 +194,20 @@ The documentation is available here: [documentation](https://pypsa-meets-africa.
</a>
</td>
<td align="center">
<a href="https://github.com/Hazem-IEG">
<img src="https://avatars.githubusercontent.com/u/87850910?v=4" width="100;" alt="Hazem-IEG"/>
<br />
<sub><b>Hazem-IEG</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/energyLS">
<img src="https://avatars.githubusercontent.com/u/89515385?v=4" width="100;" alt="energyLS"/>
<br />
<sub><b>EnergyLS</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/restyled-commits">
<img src="https://avatars.githubusercontent.com/u/65077583?v=4" width="100;" alt="restyled-commits"/>
<br />
<sub><b>Restyled Commits</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/ekatef">
<img src="https://avatars.githubusercontent.com/u/30229437?v=4" width="100;" alt="ekatef"/>
<a href="https://github.com/jarry7">
<img src="https://avatars.githubusercontent.com/u/27745389?v=4" width="100;" alt="jarry7"/>
<br />
<sub><b>Ekaterina</b></sub>
<sub><b>Jarrad Wright</b></sub>
</a>
</td></tr>
<tr>
<td align="center">
<a href="https://github.com/giacfalk">
<img src="https://avatars.githubusercontent.com/u/36954873?v=4" width="100;" alt="giacfalk"/>
<br />
<sub><b>Giacomo Falchetta</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/Tooblippe">
<img src="https://avatars.githubusercontent.com/u/805313?v=4" width="100;" alt="Tooblippe"/>
<br />
<sub><b>Jarrad Wright</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/EmreYorat">
<img src="https://avatars.githubusercontent.com/u/93644024?v=4" width="100;" alt="EmreYorat"/>
<br />
<sub><b>EmreYorat</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/squoilin">
<img src="https://avatars.githubusercontent.com/u/4547840?v=4" width="100;" alt="squoilin"/>
<br />
<sub><b>Sylvain Quoilin</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/stephenjlee">
<img src="https://avatars.githubusercontent.com/u/11340470?v=4" width="100;" alt="stephenjlee"/>
Expand Down
3 changes: 3 additions & 0 deletions doc/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ Upcoming Release

* General user experience improvements: `PR #326 <https://github.com/pypsa-meets-africa/pypsa-africa/pull/326>`__

* Fix minor validation notebook inaccuracy: `PR #332 <https://github.com/pypsa-meets-africa/pypsa-africa/pull/332>`__


PyPSA-Africa 0.0.2 (6th April 2022)
=====================================

Expand Down
29 changes: 14 additions & 15 deletions notebooks/validation/validation_nigeria.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,15 @@
"# load substation geodataframe\n",
"df_substations_osm_clean = gpd.read_file(\n",
" substations_OSMclean_path\n",
") # .to_crs(epsg=3763)\n",
") # .to_crs(epsg=3857)\n",
"df_substations_osm_clean = df_substations_osm_clean[\n",
" df_substations_osm_clean.country == \"NG\"\n",
"]\n",
"df_substations_osm_clean[\"geometry\"] = df_substations_osm_clean[\"geometry\"].apply(\n",
" make_valid\n",
")\n",
"# load lines geodataframe\n",
"df_lines_osm_clean = gpd.read_file(lines_OSMclean_path) # .to_crs(epsg=3763)\n",
"df_lines_osm_clean = gpd.read_file(lines_OSMclean_path) # .to_crs(epsg=3857)\n",
"df_lines_osm_clean = df_lines_osm_clean[df_lines_osm_clean.country == \"NG\"]\n",
"df_lines_osm_clean[\"geometry\"] = df_lines_osm_clean[\"geometry\"].apply(make_valid)"
]
Expand Down Expand Up @@ -534,7 +534,7 @@
"df_lines_osm_raw = gpd.read_file(lines_OSMraw_path)\n",
"df_lines_osm_raw = df_lines_osm_raw[df_lines_osm_raw.Country == \"NG\"]\n",
"\n",
"# note that epsg=3763 has been chosen so that lenghts are in meters"
"# note that epsg=3857 has been chosen so that lenghts are in meters"
]
},
{
Expand Down Expand Up @@ -624,7 +624,7 @@
],
"source": [
"df_lines_osm_raw[\"length_by_geometry\"] = df_lines_osm_raw.to_crs(\n",
" epsg=3763\n",
" epsg=3857\n",
").geometry.length\n",
"df_lines_osm_raw[[\"Length\", \"length_by_geometry\"]].head()"
]
Expand Down Expand Up @@ -711,7 +711,7 @@
" \"cables_fix\",\n",
"] = 3 # when NaN or None, set default value\n",
"df_lines_osm_raw[\"length\"] = (\n",
" df_lines_osm_raw.to_crs(epsg=3763).geometry.length\n",
" df_lines_osm_raw.to_crs(epsg=3857).geometry.length\n",
" * df_lines_osm_raw[\"cables_fix\"].astype(float)\n",
" / 3\n",
")\n",
Expand Down Expand Up @@ -742,7 +742,7 @@
}
],
"source": [
"df_lines_osm_raw.to_crs(epsg=3763).length.sum() / 1000"
"df_lines_osm_raw.to_crs(epsg=3857).length.sum() / 1000"
]
},
{
Expand Down Expand Up @@ -772,7 +772,7 @@
],
"source": [
"# Note, since CRS EPSG:3763 is used, distances are in meters, thus by dividing for 1000, the units are in km\n",
"df_lines_osm_raw.to_crs(epsg=3763)[\n",
"df_lines_osm_raw.to_crs(epsg=3857)[\n",
" df_lines_osm_raw[\"tags.cables\"].isnull()\n",
" | df_lines_osm_raw[\"tags.cables\"].isna() # when NaN or None, set default value\n",
"].geometry.length.sum() / 1000"
Expand Down Expand Up @@ -813,7 +813,7 @@
"source": [
"# Note, since CRS EPSG:3763 is used, distances are in meters, thus by dividing for 1000, the units are in km\n",
"df_lines_osm_clean[\"length\"] = (\n",
" df_lines_osm_clean.to_crs(epsg=3763).geometry.length\n",
" df_lines_osm_clean.to_crs(epsg=3857).geometry.length\n",
" * df_lines_osm_clean.circuits\n",
" / 1000\n",
")\n",
Expand Down Expand Up @@ -844,7 +844,7 @@
}
],
"source": [
"df_lines_osm_clean.to_crs(epsg=3763).length.sum() / 1000"
"df_lines_osm_clean.to_crs(epsg=3857).length.sum() / 1000"
]
},
{
Expand All @@ -868,7 +868,7 @@
],
"source": [
"df_lines_osm_clean[\"length\"] = (\n",
" df_lines_osm_clean.to_crs(epsg=3763).geometry.length\n",
" df_lines_osm_clean.to_crs(epsg=3857).geometry.length\n",
" * df_lines_osm_clean.circuits\n",
" / 1000\n",
")\n",
Expand Down Expand Up @@ -1107,7 +1107,7 @@
"hash": "80b8e479329add50790c5c5f77c522cbd54126228b383995b70e0610cb78cfa9"
},
"kernelspec": {
"display_name": "Python 3.9.6 64-bit ('toast': conda)",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -1121,10 +1121,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
},
"orig_nbformat": 4
"version": "3.10.4"
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}

0 comments on commit 0c8c8c2

Please sign in to comment.