add tip list
This commit is contained in:
parent
7b9d7734ab
commit
c733cf64e1
12 changed files with 598 additions and 187 deletions
48
align_trinkbrunnen.py
Normal file
48
align_trinkbrunnen.py
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
import rasterio
|
||||
import geopandas as gpd
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
# --- CONFIG ---
|
||||
raster_path = 'geodata/s2_2025.tif'
|
||||
geojson_path = 'geodata/Trinkbrunnen_Berlin.geojson'
|
||||
|
||||
# --- LOAD RASTER ---
|
||||
with rasterio.open(raster_path) as src:
|
||||
map_img = src.read([1, 2, 3])
|
||||
map_img = np.transpose(map_img, (1, 2, 0))
|
||||
map_transform = src.transform
|
||||
map_crs = src.crs
|
||||
map_bounds = src.bounds
|
||||
map_width = src.width
|
||||
map_height = src.height
|
||||
|
||||
# --- LOAD GEOJSON ---
|
||||
gdf = gpd.read_file(geojson_path)
|
||||
if gdf.crs != map_crs:
|
||||
gdf = gdf.to_crs(map_crs)
|
||||
|
||||
# --- PROJECT POINTS TO PIXELS ---
|
||||
pixel_positions = []
|
||||
for geom in gdf.geometry:
|
||||
if geom and geom.type == 'Point':
|
||||
x, y = geom.x, geom.y
|
||||
px, py = ~map_transform * (x, y)
|
||||
pixel_positions.append((int(px), int(py)))
|
||||
|
||||
# --- VISUALIZE ---
|
||||
|
||||
plt.figure(figsize=(10, 10))
|
||||
plt.imshow(map_img)
|
||||
for px, py in pixel_positions:
|
||||
plt.scatter(px, py, c='deepskyblue', s=40, edgecolors='black', label='Trinkbrunnen')
|
||||
plt.title('Trinkbrunnen auf der Berlin-Karte')
|
||||
plt.axis('off')
|
||||
plt.savefig('datenvisualisierung/trinkbrunnen_karte.png', bbox_inches='tight', dpi=200)
|
||||
plt.show()
|
||||
|
||||
# --- EXPORT PIXEL POSITIONS FOR GAME ---
|
||||
# Save as npy for easy loading in pygame
|
||||
np.save('trinkbrunnen_pixel_positions.npy', np.array(pixel_positions))
|
||||
|
||||
print(f"{len(pixel_positions)} Trinkbrunnen-Pixelpositionen wurden in trinkbrunnen_pixel_positions.npy gespeichert.")
|
||||
Loading…
Add table
Add a link
Reference in a new issue