Skip to content

Instantly share code, notes, and snippets.

@brauliobarahona
Created December 19, 2022 22:31
Show Gist options
  • Select an option

  • Save brauliobarahona/1c28dc52648d6696d35a5ba1484a0037 to your computer and use it in GitHub Desktop.

Select an option

Save brauliobarahona/1c28dc52648d6696d35a5ba1484a0037 to your computer and use it in GitHub Desktop.
Join data from Swiss solar PV installations to solar PV potential
xtf_id Address PostCode Municipality Canton BeginningOfOperation InitialPower TotalPower MainCategory SubCategory PlantCategory _x _y
14727 Schlosstrasse 15 4147 Aesch BL BL 05.05.09 14.65 18.81 maincat_2 subcat_2 plantcat_9 2611935.574 1257010.652
14728 Ob der Steig 1 5082 Kaisten AG 28.10.11 5.80 5.80 maincat_2 subcat_2 plantcat_8 2645758.387 1265094.285
10164 Gässli 4 3114 Wichtrach BE 07.10.08 3.00 3.00 maincat_2 subcat_2 plantcat_8 2610546.709 1188978.725
10794 Diemtigtalstrasse 46 3753 Oey BE 27.06.08 8.40 8.40 maincat_2 subcat_2 plantcat_8 2610528.945 1167345.635
9476 Holzweidstrasse 8 8340 Hinwil ZH 21.04.06 4.80 4.80 maincat_2 subcat_2 plantcat_8 2705863.006 1240552.876
? xxxx_strasse X 7556;7559 Valsot GR dd.mm.yy X.X0 X.X0 maincat_? subcat_? plantcat_? 2831972.730 1201616.228
index SB_UUID GWR_EGID XCOORD YCOORD EPV_kWh_a EPV_kWh_a_std APV APV_std Gt_kWh_m2_a Gt_kWh_m2_a_std APV_ratio EPV_kWh_m2roof_a swiss1 swiss2
2190367 {F5D9DCCE-EC58-4664-9074-E49FE763C2E7} 9039244.0 832035.649618 201584.597882 1678.2975 1886.373859 12.366106 12.564058 971.961470 318.558075 0.161021 21.853434 2832035.650 1201584.598
1709861 {BFD66DF5-991D-4EAC-8D0C-C5DFBAB58887} NaN 831998.548072 201584.490129 1969.4546 1241.612441 13.353165 6.594416 1055.492671 353.203034 0.158291 23.346354 2831998.548 1201584.490
1150908 {81143FD5-7C65-484D-9765-DAC10A9C4147} 1189691.0 831972.729884 201616.227761 10238.1880 4501.124043 64.684169 17.682369 1137.000829 351.426088 0.577210 91.360616 2831972.730 1201616.228
import pandas as pd
# read pv installations
installations= pd.read_csv("pv_installations_snippet.csv", sep=",").set_index(["_x","_y"]).sort_index()
# read locations with PV potential from https://zenodo.org/record/3609833#.Y6DkwC8w1pQ - but post-processed with "swiss" coordinates
potential = pd.read_csv("rooftop_PV_CH_annual_by_building_snippet.csv", sep=",", index_col="index").set_index(["swiss1", "swiss2"]).sort_index()
potential.index.rename(["_x","_y"], inplace=True)
# join potential to installations by index, I guess that there are less installations than locations with some PV potential,
#but you could also do it the other way around
installations.join(potential)
# join and drop rows that do not match potential to installations
installations.join(potential).dropna(axis=0, thresh=len(installations.keys())+1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment