Last active
February 22, 2024 11:59
-
-
Save ei-grad/1c91fbdcfdfb59fe2ee5da1dfad1559b to your computer and use it in GitHub Desktop.
Draw OSM geometries over each other projected to 1km units
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# | |
# Draw OSM geometries over each other projected to 1km units | |
# | |
# Install requirements: | |
# pip install osmnx matplotlib | |
# | |
# Usage: | |
# draw-projected "Cyprus island" "RU-MOW" | |
# | |
# Copyright (c) 2024 Andrew Grigorev <[email protected]> | |
# | |
# This software is licensed under the MIT License - see the MIT License for details: | |
# https://opensource.org/licenses/MIT | |
import sys | |
import matplotlib.pyplot as plt | |
import osmnx as ox | |
def norm(gdf): | |
gdf = gdf.to_crs(gdf.estimate_utm_crs()) | |
centroid = gdf.geometry.unary_union.centroid | |
gdf = gdf.translate(-centroid.x, -centroid.y) | |
return gdf.scale(.001, .001, origin=(0, 0)) | |
ax = plt.axes() | |
for i in sys.argv[1:]: | |
gdf = ox.geocode_to_gdf(i) | |
norm(gdf).plot(ax=ax, facecolor="none") | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment