Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify network lead to a bug in GADM shapes #382

Open
2 of 4 tasks
pz-max opened this issue Jun 16, 2022 · 1 comment
Open
2 of 4 tasks

Simplify network lead to a bug in GADM shapes #382

pz-max opened this issue Jun 16, 2022 · 1 comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed

Comments

@pz-max
Copy link
Member

pz-max commented Jun 16, 2022

Checklist

  • I am using the current main branch or the latest release. Please indicate.
  • I am running on an up-to-date pypsa-africa environment. Update via conda env update -f envs/environment.yaml.

Describe the Bug

Summary of bugs:

  • Administrative zone is removed in gadm_regions to onshore_regions conversion
  • Multiple administrative zones are associated to one shape after simplify_network.

I am running PyPSA-Africa for Nigeria with the GADM clustering option which retrieves GADM shapes also known as administrative zones. See the automatic download:
gadm-shapes
Creating the regions_onshore looks still fine. I am not sure yet what the colour change means. Maybe it is indicating an error? One bug is that black hole inside Africa!
regions_onshore
Nevertheless, the real bug appears when running simplify_network.py which then creates networks/elec_s{simpl}.nc. As you can see, hovering over one shape, it seems that some shapes are combined.
regions_onshore_elec_s

One needs to debug simplify_network and investigate the step where this occurs. We need to find a solution to this issue.

@pz-max pz-max added bug Something isn't working help wanted Extra attention is needed good first issue Good for newcomers labels Jun 16, 2022
@jome1
Copy link

jome1 commented Jul 1, 2024

I think I know now why some shapes are weirdly combined when hovering over them and why the there is the color change. (or at least it is a puzzle piece :)

It is because the single polygons do not conterminous properly anymore. To see this, you have to zoom in a lot (maybe use QGIS to better analyse).
In the script build_shapes.py the GADM zones are downloaded and then simplified. During this simplification holes and overlaps between the polygons can occur. (See #1051)

The simplification in the script build_shapes.py is done with shapely.simplify

To solve this problem, shared boarders of conterminous (neighbouring) polygons should not be simplified or the neighbouring polygons have to be simplified to the same line.

I did a little internet search.
Maybe shapely.snap could help to solve this problem.
Here is also a helpful mini thread about this phenomenon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants