Open cpschau opened 1 year ago
@cschau-ieg, thanks a lot for the detailed report. Very nice plots!
Absolutely agree that if something gets wrong during network simplification, it should be fixed there. A couple of clarification questions:
1) Could you please explain in a bit more details why buses assignment in the first picture is wrong? Is each bus in fact outside of the corresponding shape?
2) Agree that regarding merging four GADM regions doesn't look right, but do not quite understand in which way it is connected with the assignment. Could you please explain in a bit more details?
Hey @ekatef ,
dissolve
, which in our case merges the geometries of the GeoDataframe regions
according to the busmap, which is provided as an argument of the function. So let's assume that the buses b_1 and b_2 are contained in the shape s_1 and so it is correctly specified in the busmap. However, the row of the Geodataframe regions
(which originates from regions_onshore_elec_s.geojson) assigns b_1 implicitly to a different false shape s_2 in its geometry column. Now, after regions.dissolve(busmap, aggfunc)
is executed, s_1 will comprise of the geometries of s_1 and s_2.@cschau-ieg, thanks a lot for the detailed explanations! The issue looks really interesting, and some detailed debugging seems to be needed to resolve it. Let's try to tackle that step-by-step:
First of all, I'd do couple of safety checks:
I recognise that it sounds almost idiotic, but in many cases works surprisingly well. Saying from personal experience ;)
busmap_for_gadm_clusters
(is included into clustering_for_n_clusters
which is actually defined in cluster_network
script) locates each bus correctly in simplify_network
and cluster_network
.I fear there might be some issues with tolerance of the buses of shapes coordinates. So, it's crucial to understand what is going on when the buses are being matched against the onshore/offshore shapes
Thank you for the recommendation, @ekatef! Updating and cleaning the repo indeed improved the situation. Nonetheless, there is still one shape anomaly occuring for the region of the outlier bus, which is depicted in the third figure of the first post. I plotted them again, so the intersections become visible.
FYI I experienced this issue with Africa as well, but in my case the issue is that some countries are missing for some reasons. That may be due to problems in simplify_network or before.
Update: the problem is in remove_stubs
Checklist
[x ] I am using the current
main
branch or the latest release. Please indicate.Latest release, but 38 commits behind pypsa-meets-earth:main
[ x] I am running on an up-to-date
pypsa-earth
environment. Update viaconda env update -f envs/environment.yaml
.Describe the Bug
if 'elec_s_' in os.path.basename(output[0]) and which == "regions_onshore":
gadm_shapes = gpd.read_file(inputs.gadm_shapes)
regions["geometry"] = regions.apply(lambda r:
gadm_shapes.loc[gadm_shapes.GADM_ID == busmap.loc[r.name][:-3], "geometry"].item(),
axis=1
)