Last active
January 24, 2022 05:39
-
-
Save MaxvanHaastrecht/6e2b8345766e157325a8e99a0fe76168 to your computer and use it in GitHub Desktop.
Importing roads and plotting as a city street map
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
| import geopandas as gpd | |
| import matplotlib.pyplot as plt | |
| # Import all roads NL | |
| map_df = gpd.read_file('roads.shp') | |
| # Show data format | |
| map_df.head() | |
| # Set image properties | |
| fig, ax = plt.subplots(1, figsize=(10,14)) | |
| map_df.plot(cmap='Wistia', ax=ax) | |
| ax.axis('off') | |
| # Set coordinates to match Utrecht, change for your own city | |
| ax.set_xlim(5.1050, 5.1400) | |
| ax.set_ylim(52.0620, 52.1115) | |
| ax.set_aspect('equal') | |
| # Plot the street map of Utrecht | |
| plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment