Plotting with GeoJSON

Visualizing Geospatial Data in Python

Mary van Valkenburg

Data Science Program Manager, Nashville Software School

Neighborhoods GeoJSON

{ "type": "FeatureCollection",
  "features": [
    { "type":"Feature",
      "properties":{
    "name":"Historic Buena Vista"
    },"geometry":{
        "type":"MultiPolygon","coordinates":[[[[-86.79511056795417,36.17575....
neighborhoods = gpd.read_file('./data/neighborhood_boundaries.geojson')
neighborhoods.head(1)
        name             geometry
Historic Buena Vista    (POLYGON ((-86.79511056795417 36.17575964963348...)))
Visualizing Geospatial Data in Python

Geopandas dependencies

raster and vector representations

  • Fiona
    • provides an python API for OGR
  • GDAL/OGR
    • GDAL for translating raster data
    • OGR for translating vector data
Visualizing Geospatial Data in Python

Comparing raster and vector graphics

raster image of Corfu raster image of Corfu

vector image of Corfu vector image of Corfu

Visualizing Geospatial Data in Python

Colormaps

Visualizing Geospatial Data in Python

Plotting with color

school_districts.head(3)
first_name     last_name    position    district      geometry
Sharon         Gentry       Member       1    (POLYGON ((-86.771 36.383)...))
Jill           Speering     Vice-Chair   3    (POLYGON ((-86.753 36.404)...))
Jo Ann         Brannon      Member       2    (POLYGON ((-86.766 36.083)...))

comparing color maps

Visualizing Geospatial Data in Python
council_dists.plot(
                   column='district', 
                   cmap='Set3', 
                   legend=True)
plt.title('Council Districts')
plt.show();

council district plot with long legend

leg_kwds={'title':'District Number', 
          'loc': 'upper left', 
          'bbox_to_anchor':(1, 1.03), 
          'ncol':3}
council_dists.plot(column='district', 
                   cmap='Set3',
                   legend=True, 
             legend_kwds=leg_kwds)
plt.title('Council Districts')
plt.show();

council district plot with multicolumn legend

Visualizing Geospatial Data in Python

Let's practice!

Visualizing Geospatial Data in Python

Preparing Video For Download...