# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# + [markdown] pycharm={"name": "#%% md\n"}
# # Data Preparation
#
# This notebook is used to prepare the data for the model.

# + [markdown] pycharm={"name": "#%% md\n"}
# 1. Import the necessary libraries

# + pycharm={"name": "#%%\n"}
import pandas as pd

# + pycharm={"name": "#%%\n"}


# + [markdown] pycharm={"name": "#%% md\n"}
# 2. Read cleaned data

# + pycharm={"name": "#%%\n"}
df = pd.read_csv('processed/cleaned_data.csv')

# + pycharm={"name": "#%%\n"}
df.head(5)
# -

# 3. Prepare data for schools

# + pycharm={"name": "#%%\n"}
# Comparing area of source school and target school
# Source school is the school from which data is collected.

floor_area_of_source = 27,000
floor_area_of_school = 0
# -

# 4. Prepare data for offices

# + pycharm={"name": "#%%\n"}

# -

# 5. Prepare data for residential buildings

# + pycharm={"name": "#%%\n"}

# -

# 6. Prepare data for EV-bus charging stations

# + pycharm={"name": "#%%\n"}

# -

# 7. Combine all data

# + pycharm={"name": "#%%\n"}


# + [markdown] pycharm={"name": "#%% md\n"}
# 8. Store data in a csv file

# + pycharm={"name": "#%%\n"}


# + pycharm={"name": "#%%\n"}
import fiona

# + pycharm={"name": "#%%\n"}
shape = fiona.open("raw/GIS/GIS/Warmtenet.shp")

# + pycharm={"name": "#%%\n"}
shape.plot()

# + pycharm={"name": "#%%\n"}
print (shape.schema)

# + pycharm={"name": "#%%\n"}
first = shape.next()
print (first)

# + pycharm={"name": "#%%\n"}
import geopandas as gpd

# + pycharm={"name": "#%%\n"}
# heat_network = gpd.read_file("raw/GIS/GIS/Warmtenet.shp")
buildings = gpd.read_file("raw/GIS/GIS/Initiatieven.shp")
neighborhoods = gpd.read_file("raw/GIS/GIS/Data/Buurten/Buurten.shp")
neighborhood_energy_code = gpd.read_file("raw/GIS/GIS/Data/Download-BuurtEnergieInfo-SHP/BuurtEnergieCodes_v.shp")

# + pycharm={"name": "#%%\n"}
buildings.to_crs(epsg=4326, inplace=True)

# + pycharm={"name": "#%%\n"}
buildings.crs

# + pycharm={"name": "#%%\n"}
buildings = buildings[buildings['Initiatief'] != '<NAME>']

# + pycharm={"name": "#%%\n"}
fig, ax = plt.subplots(1, figsize=(10,10))
# heat_network.plot(ax=ax, color='red')
# neighborhoods.plot(ax=ax, color='green')
# neighborhood_energy_code.plot(ax=ax, color='green')
buildings.plot(ax=ax, color='blue')

# + pycharm={"name": "#%%\n"}
buildings_json = buildings['geometry'].to_json()


# + pycharm={"name": "#%%\n"}
import plotly.express as px

# + pycharm={"name": "#%%\n"}
token = '<KEY>'

# + pycharm={"name": "#%%\n"}
fig = px.choropleth_mapbox(buildings, locations='id',
                    color='Initiatief',
                    geojson=buildings_json,
                    hover_name='Initiatief',
                    center={"lat": 51.59926, "lon": 4.80896},
                    mapbox_style="carto-positron",
                    opacity=0.5,
                    zoom=13,)
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
fig.show()

# + pycharm={"name": "#%%\n"}
buildings

# + pycharm={"name": "#%%\n"}


StarcoderdataJupyterScriptsDedupFiltered