AlexanderSvarfdal commited on
Commit
09f4780
·
1 Parent(s): 99932ef

added stuff

Browse files
.DS_Store CHANGED
Binary files a/.DS_Store and b/.DS_Store differ
 
data_processing/get_station_coverage.py CHANGED
@@ -55,7 +55,7 @@ if __name__ == '__main__':
55
  radius_meters = 400 # 400 meters
56
 
57
  # Get small areas
58
- covered_areas = get_station_coverage(get_smallAreas("given_data/smasvaedi_2021.json"), station_coords, radius_meters)
59
 
60
  # Print results
61
  for area in covered_areas:
 
55
  radius_meters = 400 # 400 meters
56
 
57
  # Get small areas
58
+ covered_areas = get_station_coverage(get_smallAreas(), station_coords, radius_meters)
59
 
60
  # Print results
61
  for area in covered_areas:
data_processing/point_scoring.py CHANGED
@@ -47,6 +47,8 @@ def score_current(station_coord, df_features, cov_smsv, w_density, w_income, w_a
47
  # 1. Get small area ids in range
48
  # 2.
49
  # Score = [for all areas in range((density) * coverage percentage)]
 
 
50
  final_score = 0
51
  for smsv in cov_smsv:
52
 
@@ -64,7 +66,7 @@ def score_current(station_coord, df_features, cov_smsv, w_density, w_income, w_a
64
  income_score = get_income_score(smsv_info["income_distribution_per_year"]) * w_income
65
 
66
  density_score = smsv_info["density"].iloc[0] * w_density
67
- final_score += (age_score + income_score + density_score) * smsv["coverage_percentage"]
68
  return final_score
69
 
70
  def get_age_score(smsv_age_dict):
 
47
  # 1. Get small area ids in range
48
  # 2.
49
  # Score = [for all areas in range((density) * coverage percentage)]
50
+
51
+ # TODO: take into account fjoldi starfandi, if there are more people who work than live => many people need to get there, also works the other way around.
52
  final_score = 0
53
  for smsv in cov_smsv:
54
 
 
66
  income_score = get_income_score(smsv_info["income_distribution_per_year"]) * w_income
67
 
68
  density_score = smsv_info["density"].iloc[0] * w_density
69
+ final_score += (age_score + income_score + density_score) * smsv["coverage_percentage"] # TODO: Area of the cricle * percent covered / total area of the small area
70
  return final_score
71
 
72
  def get_age_score(smsv_age_dict):
given_data/borgarlina_ggplot.py CHANGED
@@ -53,3 +53,4 @@ for _, row in filtered_smallarea.iterrows():
53
 
54
  ax.set_title("Filtered Small Areas with IDs Written Inside")
55
  plt.show()
 
 
53
 
54
  ax.set_title("Filtered Small Areas with IDs Written Inside")
55
  plt.show()
56
+
given_data/test.py ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import geopandas as gpd
2
+ import pandas as pd
3
+ import matplotlib.pyplot as plt
4
+ from shapely.geometry import Point
5
+
6
+ # Load data (assuming file paths are correct)
7
+ lina1 = gpd.read_file("given_data/cityline_geojson/cityline_2025.geojson")
8
+ pop = pd.read_csv("given_data/ibuafjoldi.csv")
9
+ smallarea = gpd.read_file("given_data/smasvaedi_2021.json")
10
+ dwellings = pd.read_csv("given_data/ibudir.csv")
11
+
12
+ # Reproject to EPSG:3057 (projected CRS for Iceland, distances in meters)
13
+ lina1 = lina1.to_crs(epsg=3057)
14
+ smallarea = smallarea.to_crs(epsg=3057)
15
+
16
+ # Add 400m radius circle using projected coordinates
17
+ # Define station coordinates (in EPSG:3057)
18
+ station_x = 356250.0
19
+ station_y = 408250.0
20
+
21
+ # Create a Shapely Point for the station
22
+ station_point = Point(station_x, station_y)
23
+
24
+ # Create a 400-meter buffer around the station
25
+ buffered_circle = station_point.buffer(400) # 400 meters in projected CRS
26
+
27
+ # Convert the circle into a GeoDataFrame for plotting
28
+ circle_gdf = gpd.GeoDataFrame(geometry=[buffered_circle], crs="EPSG:3057")
29
+
30
+ # Data processing
31
+ pop['smasvaedi'] = pop['smasvaedi'].astype(str).str.zfill(4)
32
+ pop2024 = pop[(pop['ar'] == 2024) & (pop['aldursflokkur'] == "10-14 ára") & (pop['kyn'] == 1)]
33
+ pop2024_smallarea = pd.merge(smallarea, pop2024, left_on='smsv', right_on='smasvaedi', how='left')
34
+
35
+ # Filter for nuts3 == "001"
36
+ filtered_smallarea = pop2024_smallarea[pop2024_smallarea['nuts3'] == "001"]
37
+
38
+ # Plot the filtered small areas and write the IDs
39
+ fig, ax = plt.subplots(1, 1, figsize=(10, 10)) # Adjust figsize as needed
40
+ filtered_smallarea.plot(ax=ax, facecolor='none', edgecolor='blue') # Plot small areas with blue borders
41
+ lina1.plot(ax=ax, facecolor='none', edgecolor='black') # Plot cityline data
42
+ circle_gdf.plot(ax=ax, facecolor='none', edgecolor='red', linewidth=2) # Add the circle in red
43
+ # Set x and y axis limits to zoom into the area
44
+ ax.set_xlim(355500, 357000) # Adjust to your desired x-axis range
45
+ ax.set_ylim(407500, 409000) # Adjust to your desired y-axis range
46
+
47
+ # Add IDs as text labels
48
+ for _, row in filtered_smallarea.iterrows():
49
+ # Get the centroid of each small area
50
+ centroid = row.geometry.centroid
51
+ # Place the ID as text at the centroid
52
+ ax.text(centroid.x, centroid.y, str(row['smsv']), fontsize=8, color='darkred', ha='center')
53
+
54
+ ax.set_title("Filtered Small Areas with IDs Written Inside")
55
+ plt.show()