A map with the average price per square meters of building land for all Austrian munucipalities.
The map below shows the average price per square meters of building land for all Austrian munucipalities (Gemeinden) as per 2020.
Code
import altair as alt
import pandas as pd
preise_url = "https://www.statistik.at/wcm/idc/idcplg?IdcService=GET_NATIVE_FILE&RevisionSelectionMethod=LatestReleased&dDocName=126150"
preise_urls = {
"2016": "https://raw.githubusercontent.com/markusschanta/mslib/master/mslib/data/baugrundstueckspreise/files/baugrundstueckspreise_2016.xlsx",
"2017": "https://raw.githubusercontent.com/markusschanta/mslib/master/mslib/data/baugrundstueckspreise/files/baugrundstueckspreise_2017.xlsx",
"2018": "https://raw.githubusercontent.com/markusschanta/mslib/master/mslib/data/baugrundstueckspreise/files/baugrundstueckspreise_2018.xlsx",
"2019": "https://raw.githubusercontent.com/markusschanta/mslib/master/mslib/data/baugrundstueckspreise/files/baugrundstueckspreise_2019.xlsx",
"2020": "https://raw.githubusercontent.com/markusschanta/mslib/master/mslib/data/baugrundstueckspreise/files/baugrundstueckspreise_2020.xlsx"
}
gemeinden_url = "https://raw.githubusercontent.com/ginseng666/GeoJSON-TopoJSON-Austria/master/2021/simplified-99.5/gemeinden_995_topo.json"
gemeinden = alt.topo_feature(gemeinden_url, "gemeinden")
def get_preise(year):
xl = pd.ExcelFile(preise_urls[year], engine='openpyxl')
combined = []
for s in xl.sheet_names:
sheet = pd.read_excel(xl, engine='openpyxl', header=3, sheet_name=s)
sheet = sheet.iloc[:, -3:]
sheet.columns = ['iso', 'name', 'price']
combined.append(sheet.loc[~sheet.iso.isnull()])
return pd.concat(combined).reset_index(drop=True)
preise = get_preise("2020")
# preise.price = preise.price.clip(upper=300)
c = alt.Chart(gemeinden).mark_geoshape().encode(
color=alt.Color('price:Q', title='Price', scale=alt.Scale(domain=[8, 2000], type='log', scheme='spectral', reverse=True)),
tooltip=['name:N','price:Q']
).transform_lookup(
lookup='properties.iso',
from_=alt.LookupData(preise, 'iso', ['price', 'name'])
).properties(
width=600,
height=310
)
c