I recently downloaded the shapefiles from San Francisco from Mapzen. Now I am able to display the streets, but I would like to have a real map as a background image, such that it is easier to make the link between the real roads from San Francisco and the ones shown by Geopandas.
Here is the code to show the streets with Geopandas:
First Download the shaepfile from Mapzen: https://s3.amazonaws.com/metro-extracts.mapzen.com/san-francisco_california.imposm-shapefiles.zip
Open a Python notebook and add those lines:
#Useful starting lines %matplotlib inline import numpy as np import matplotlib.pyplot as plt %load_ext autoreload %autoreload 2
Load the street map:
shapefile_dir = 'the path to your directory where you store the shapefile'
shapefile_name ='san-francisco_california_osm_roads_gen0.shp'
shapefile_roads = os.path.join(shapefile_dir, shapefile_name)
Import as a geopandas dataframe:
import os
import geopandas as gpd
df = gpd.GeoDataFrame.from_file(shapefile_roads)
Simply plot the street network:
df.plot();
The output should be:
Now I would like to have a real map (Color map) as a background. How can I do it ?