This code was written as a research assignment for Smart Cities Seminar by Dr. Efrat Blumenfeld Lieberthal.
-
Download OSM dataset of Illinois from https://download.geofabrik.de/north-america/us/illinois.html
-
Use osm2psql tool to translate to postgres:
osm2pgsql --slim --username noa --database chicago illinois-latest.osm.pbf
Database password: postgres.
-
Use only data in wanted relevant polygon - use
Select by Location
feature. Reference: https://gis.stackexchange.com/questions/61753/selecting-features-within-polygon-from-another-layer-using-qgis -
Create a new layer out of selected features: https://gis.stackexchange.com/questions/26198/creating-new-layer-from-selection-in-qgis
-
Split with lines (Toolbox) - break lines at intersections. Reference: https://gis.stackexchange.com/questions/247013/splitting-a-polyline-at-intersections
-
Explode lines (Toolbox) - exploding lines into segments. Reference: https://gis.stackexchange.com/questions/271806/exploding-line-into-segments-using-qgis
-
Calculate length of each polyline into a new field.
-
Remove lines with length < 1.
-
Locate points along lines (external plugin) - create a layer of points from polylines. Tick "add endpoint" and "keep attributes".
-
Add x and y coordinates - in
Toolbox
search forAdd geometry attributes
.