fix: final results generated
This commit is contained in:
parent
00e2a9d9bf
commit
29e4f26b30
578
buildings_map_colored.html
Normal file
578
buildings_map_colored.html
Normal file
File diff suppressed because one or more lines are too long
@ -176,7 +176,8 @@ class PvSystemAssessment:
|
||||
'yearly_total_pv_production_kWh': sum(total_hourly_pv_output) / 1000,
|
||||
'specific_pv_production_kWh/kWp': sum(rooftop_pv_output) / (
|
||||
float(self.pv_system.standard_test_condition_maximum_power) * rooftop_number_of_panels),
|
||||
'hourly_rooftop_poa_irradiance_W/m2': self.building.roofs[0].global_irradiance_tilted[cte.HOUR],
|
||||
'hourly_rooftop_irradiance_W/m2': self.building.roofs[0].global_irradiance[cte.HOUR],
|
||||
'hourly_pv_poa_irradiance_W/m2': self.building.roofs[0].global_irradiance_tilted[cte.HOUR],
|
||||
'hourly_rooftop_pv_output_W': rooftop_pv_output, 'T_out': self.building.external_temperature[cte.HOUR],
|
||||
'building_electricity_demand_W': electricity_demand,
|
||||
'total_hourly_pv_system_output_W': total_hourly_pv_output, 'import_from_grid_W': imported_electricity,
|
||||
|
93
final_results.py
Normal file
93
final_results.py
Normal file
@ -0,0 +1,93 @@
|
||||
import folium
|
||||
import geopandas as gpd
|
||||
from pathlib import Path
|
||||
import json
|
||||
|
||||
# Load the GeoJSON file and ensure the 'id' field is included
|
||||
geojson_path = Path(__file__).parent / 'input_files' / 'buildings_to_map.geojson'
|
||||
with open(geojson_path, 'r') as f:
|
||||
geojson_data = json.load(f)
|
||||
|
||||
# Convert GeoJSON to GeoDataFrame, explicitly adding 'id' as a column
|
||||
geo_data = gpd.GeoDataFrame.from_features(geojson_data["features"])
|
||||
geo_data["id"] = [feature["id"] for feature in geojson_data["features"]]
|
||||
|
||||
# Ensure the GeoDataFrame has a CRS (assuming WGS84 if not already defined)
|
||||
if geo_data.crs is None:
|
||||
geo_data.set_crs(epsg=4326, inplace=True)
|
||||
|
||||
|
||||
# Function to assign colors based on building function
|
||||
def get_color(building_function):
|
||||
color_map = {
|
||||
"residential": "lightblue", # Changed from blue to lightblue for better text visibility
|
||||
"secondary school": "green",
|
||||
"medium office": "red",
|
||||
"sports location": "orange", # Example for your data
|
||||
"stand alone retail": "purple"
|
||||
}
|
||||
return color_map.get(building_function, "gray") # Default color is gray
|
||||
|
||||
|
||||
# Create a style function for the GeoJson layer
|
||||
def style_function(feature):
|
||||
building_function = feature["properties"].get("function", "unknown")
|
||||
return {
|
||||
"fillColor": get_color(building_function),
|
||||
"color": "black", # Outline color
|
||||
"weight": 1,
|
||||
"fillOpacity": 0.6
|
||||
}
|
||||
|
||||
|
||||
# Get the centroid coordinates for the map center
|
||||
centroid = geo_data.geometry.centroid.iloc[0]
|
||||
center = (centroid.y, centroid.x) # lat, lon
|
||||
|
||||
# Create a Folium map with CartoDB Positron tiles
|
||||
m = folium.Map(location=center, zoom_start=50, tiles="CartoDB positron")
|
||||
|
||||
# Add the GeoJSON layer with color-coded styles
|
||||
folium.GeoJson(
|
||||
geojson_data,
|
||||
name="Buildings",
|
||||
style_function=style_function
|
||||
).add_to(m)
|
||||
|
||||
# Add labels for each building
|
||||
for _, row in geo_data.iterrows():
|
||||
feature_id = row['id'] # Access the 'id' attribute
|
||||
feature_centroid = row['geometry'].centroid # Get the centroid of the feature
|
||||
|
||||
# Create a rotated label
|
||||
folium.Marker(
|
||||
location=(feature_centroid.y, feature_centroid.x),
|
||||
icon=folium.DivIcon(html=f'<div style="transform: rotate(90deg); font-size: 14px;">{feature_id}</div>')
|
||||
).add_to(m)
|
||||
|
||||
# Add a legend to the map
|
||||
legend_html = '''
|
||||
<div style="
|
||||
position: fixed;
|
||||
bottom: 30px; left: 30px; width: 250px; height: 200px;
|
||||
background-color: white;
|
||||
border:2px solid grey; z-index:9999; font-size:14px;
|
||||
padding: 10px; box-shadow: 2px 2px 5px rgba(0,0,0,0.3);">
|
||||
<b>Legend</b><br>
|
||||
<i style="background: lightblue; width: 10px; height: 10px; display: inline-block; margin-right: 5px;"></i> Residential<br>
|
||||
<i style="background: green; width: 10px; height: 10px; display: inline-block; margin-right: 5px;"></i> Secondary School<br>
|
||||
<i style="background: red; width: 10px; height: 10px; display: inline-block; margin-right: 5px;"></i> Medium Office<br>
|
||||
<i style="background: orange; width: 10px; height: 10px; display: inline-block; margin-right: 5px;"></i> Sports Location<br>
|
||||
<i style="background: purple; width: 10px; height: 10px; display: inline-block; margin-right: 5px;"></i> Stand Alone Retail<br>
|
||||
</div>
|
||||
'''
|
||||
m.get_root().html.add_child(folium.Element(legend_html))
|
||||
|
||||
# Add a layer control to toggle layers
|
||||
folium.LayerControl().add_to(m)
|
||||
|
||||
# Save the map as an HTML file
|
||||
map_output_path = 'buildings_map_colored_with_legend.html'
|
||||
m.save(map_output_path)
|
||||
|
||||
print(f"Map saved as {map_output_path}")
|
1971
input_files/buildings_to_map.geojson
Normal file
1971
input_files/buildings_to_map.geojson
Normal file
File diff suppressed because it is too large
Load Diff
1971
input_files/modified_buildings.geojson
Normal file
1971
input_files/modified_buildings.geojson
Normal file
File diff suppressed because it is too large
Load Diff
@ -87,7 +87,7 @@ for building in city.buildings:
|
||||
system_catalogue_handler='montreal_future',
|
||||
roof_percentage_coverage=0.75,
|
||||
facade_coverage_percentage=0,
|
||||
csv_output=False,
|
||||
csv_output=True,
|
||||
output_path=pv_assessment_path)
|
||||
pv_modeller.enrich()
|
||||
results = pv_modeller.results
|
||||
|
Loading…
Reference in New Issue
Block a user