GIS: Territorial Analysis¶
Mehmet Haydan,
In [1]:
#importing the necessary packages
import geopandas as gpd
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
In [2]:
#loading the dataset containing the locations of the schools (up to secondary level) in Düsseldorf. The file format is .geojson and it is a point data.
schools = gpd.read_file("./ipynb/Schulen in Düsseldorf_1.geojson")
#the data is shown in the table by using the plot function of GeoPandas Dataframe. First fifteen rows were printed to check if there is any unexpected errors accured.
schools.head(15)
Out[2]:
| NAME DER SCHULE | ANSCHRIFT | BESCHREIBUNG (STADTTEIL - SCHULFORM - SCHULTRÄGER) | geometry | |
|---|---|---|---|---|
| 0 | Adolf-Klarenbach-Schule | Walther-Rathenau-Straße 15 - 40589 - Düsseldorf | Holthausen - Grundschule - Stadt Düsseldorf | POINT (6.837 51.170) |
| 1 | Albert-Einstein-Gymnasium | Zietenstraße 50 - 40476 - Düsseldorf | Golzheim - Gymnasium - Sonstiger Träger | POINT (6.779 51.243) |
| 2 | Albrecht-Dürer-Schule | Fürstenwall 100 - 40217 - Düsseldorf | Unterbilk - Berufs- Weiterbildungskolleg - Sta... | POINT (6.773 51.214) |
| 3 | Alfred-Adler-Schule - Schule für Kranke im Zen... | Moorenstraße 5 - 40225 - Düsseldorf | Bilk - Schule für Kranke - Stadt Düsseldorf | POINT (6.788 51.198) |
| 4 | Alfred-Herrhausen-Schule | Carl-Friedrich-Goerdeler-Straße 21 - 40595 - D... | Garath - Förderschule - Stadt Düsseldorf | POINT (6.903 51.146) |
| 5 | Aloys-Odenthal-Schule | Diepenstraße 24 - 40625 - Düsseldorf | Gerresheim - Grundschule - Stadt Düsseldorf | POINT (6.845 51.230) |
| 6 | Anne-Frank-Realschule | Ackerstraße 174 - 40233 - Düsseldorf | Flingern-Nord - Realschule - Stadt Düsseldorf | POINT (6.809 51.231) |
| 7 | Annette-von-Droste-Hülshoff-Gymnasium | Brucknerstraße 19 - 40593 - Düsseldorf | Benrath - Gymnasium - Stadt Düsseldorf | POINT (6.878 51.158) |
| 8 | Astrid-Lindgren-Schule | Leuthenstraße 50 - 40231 - Düsseldorf | Eller - Grundschule - Stadt Düsseldorf | POINT (6.840 51.213) |
| 9 | Benzenberg-Realschule | Siegburger Straße 38 - 40591 - Düsseldorf | Oberbilk - Realschule - Stadt Düsseldorf | POINT (6.811 51.203) |
| 10 | Berufskolleg Bachstraße | Bachstraße 8 - 40223 - Düsseldorf | Bilk - Berufs- Weiterbildungskolleg - Stadt Dü... | POINT (6.765 51.208) |
| 11 | Berufskolleg f. Informations- Kommunikations- ... | Klaus-Bungert-Straße 6 - 40468 - Düsseldorf | Unterrath - Berufs- Weiterbildungskolleg - Son... | POINT (6.766 51.273) |
| 12 | Berufskolleg Kaiserswerther Diakonie | Alte Landstraße 179 E - 40489 - Düsseldorf | Kaiserswerth - Berufs- Weiterbildungskolleg - ... | POINT (6.745 51.302) |
| 13 | Berufskolleg RheinRuhr | Ackerstraße 3 - 40233 - Düsseldorf | Stadtmitte - Berufs- Weiterbildungskolleg - So... | POINT (6.796 51.225) |
| 14 | Bonifatius-Schule | Fleher Straße 70 - 40223 - Düsseldorf | Bilk - Grundschule - Stadt Düsseldorf | POINT (6.766 51.203) |
In [3]:
#ipyleaflet library and open street map are imported for creating an interactive map.
from ipyleaflet import Map, GeoData, basemaps, LayersControl
from ipyleaflet import AwesomeIcon, Marker, Icon, Map
from ipyleaflet import Map, Marker, Popup, MarkerCluster
from ipywidgets import HTML
import osmnx as ox
from IPython.display import Image
In [4]:
#the center of the open street map is set to the central coordinates of Düsserdorf.
center = (51.2277, 6.7735)
#map information is defined, location is set for the center.
m = Map(basemap=basemaps.Esri.WorldImagery, center=center, zoom=12)
#locations of the icons are set. The specific locations for these 3 points were selected to demonstrate the oldest schools in Düsseldorf.
#Their names and years of foundation were researched separately.
oldest_school_1 = (51.22122, 6.77814)
oldest_school_2 = (51.229742, 6.772765)
oldest_school_3 = (51.2216499, 6.77611)
#to visualize the oldest schools, an icon is defined and related settings are set such as size, anchor point etc.
icon1 = Icon(icon_url='https://cdn2.iconfinder.com/data/icons/maps-and-locations/12/school-512.png', icon_size=[40, 40], icon_anchor=[0,0])
icon2 = Icon(icon_url='https://cdn2.iconfinder.com/data/icons/maps-and-locations/12/school-512.png', icon_size=[40, 40], icon_anchor=[0,0])
icon3 = Icon(icon_url='https://cdn2.iconfinder.com/data/icons/maps-and-locations/12/school-512.png', icon_size=[40, 40], icon_anchor=[0,0])
#markers are created for placing them in the open street map, informations related to their locations and appearances were connected to the previous steps.
mark1 = Marker(location=oldest_school_1, draggable=False, icon=icon1)
mark2 = Marker(location=oldest_school_2, draggable=False, icon=icon2)
mark3 = Marker(location=oldest_school_3, draggable=False, icon=icon3)
#icons are added to the map function
m.add_layer(mark1)
m.add_layer(mark2)
m.add_layer(mark3)
#geodata function is defined with the 'schools' dataframe which is connected to the original data source of .geojson and marker settings are set for all locations.
geo_data = GeoData(geo_dataframe= schools, style={'color': 'black', 'fillColor': '#3c758c', 'opacity':0.05, 'weight':1.9, 'dashArray':'2', 'fillOpacity':0.6})
#because the amount of the point data is more than +150, marker cluster function is defined. The icons are also included to the cluster.
marker_cluster = MarkerCluster(
markers=(mark1, mark2, mark3, geo_data)
)
#marker cluster is added to the map function
m.add_layer(marker_cluster)
#to define a popup function for 3 oldest school, firstly the messages and their values are created.
#Each message represents the names of the schools and their faundation years. (links to the sources can be found in the .zip)
message1 = HTML()
message1.value = "Görres-Gymnasium (1545)"
message2 = HTML()
message2.value = "St.-Ursula-Gymnasium (1677)"
message3 = HTML()
message3.value = "Luisen-Gymnasium (1837)"
#popup function is defined for the each icon location separately.
popup1 = Popup(
location=oldest_school_1,
close_button=False,
auto_close=False,
close_on_escape_key=False
)
popup2 = Popup(
location=oldest_school_2,
close_button=False,
auto_close=False,
close_on_escape_key=False
)
popup3 = Popup(
location=oldest_school_3,
close_button=False,
auto_close=False,
close_on_escape_key=False
)
#each icon is connected to their defined messages
mark1.popup = message1
mark2.popup = message2
mark3.popup = message3
#popups are added to the map function
m.add_layer(popup1)
m.add_layer(popup2)
m.add_layer(popup3)
#final result
m
Map(center=[51.2277, 6.7735], controls=(ZoomControl(options=['position', 'zoom_in_text', 'zoom_in_title', 'zoo…
In [ ]: