1 of 6

CSE 163

Geospatial Data / Geopandas

��Hunter Schafer

💬Before class: Do you like the weather in Seattle?

🎵Music: Lawrence

2 of 6

Geopandas

  • Exactly like pandas, but with some extra features for geo data
  • Types
    • GeoDataFrame
    • GeoSeries

2

import geopandas as gpd

df = gpd.read_file('data_File.shp')

df.plot(column='some_col', legend=True)

plt.savefig('plot.png')

3 of 6

zip

  • zip is a helpful built-in function to help you combine lists

  • Note: zip does not return a list! It returns a generator
    • Can only access the values by iterating over them
    • Can only be used once! Iterating “consumes” the series

3

x = [1,2,3]

y = [4,5,6]

zip(x, y)

4 of 6

Matplotlib

  • Before, we were using a lot of matplotlib stuff blindly
  • Default plots gets plotted on a global figure (think canvas)
    • Multiple plots would overwrite each other
  • You have to do extra work to get more information on the same set of axes.

4

fig, ax = plt.subplots(1)

<plot1>(ax=ax)

<plot2>(ax=ax)

fig.savefig('plot.png')

5 of 6

Hurricane Florence

5

6 of 6

Group Work:

Best Practices

When you first working with this group:

  • Introduce yourself!
  • If possible, angle one of your screens so that everyone can discuss together

Tips:

  • Starts with making sure everyone agrees to work on the same problem
  • Make sure everyone gets a chance to contribute!
  • Ask if everyone agrees and periodically ask each other questions!
  • Call TAs over for help if you need any!

6