Exercise 1

Spring 2023

Author

Serge Rey

Published

February 14, 2023

Exercise 1: Geography 385 Spring 2023

  1. Complete all the tasks below in this notebook (you must show the code used to get your answers).
  2. Save and Export As - PDF
  3. Upload your pdf to the Canvas site

Due February 16 2pm

Creating a folder

Create a folder called exercise using the File Explorer in Jupyter Hub

In that folder, copy this file, and do all your work in that file/notebook

import geopandas 
import pandas
import matplotlib.pyplot as plt
import numpy
import seaborn
import contextily
/tmp/ipykernel_324391/4095894001.py:1: UserWarning:

Shapely 2.0 is installed, but because PyGEOS is also installed, GeoPandas will still use PyGEOS by default for now. To force to use and test Shapely 2.0, you have to set the environment variable USE_PYGEOS=0. You can do this before starting the Python process, or in your code before importing geopandas:

import os
os.environ['USE_PYGEOS'] = '0'
import geopandas

In a future release, GeoPandas will switch to using Shapely by default. If you are using PyGEOS directly (calling PyGEOS functions on geometries from GeoPandas), this will then stop working and you are encouraged to migrate from PyGEOS to Shapely 2.0 (https://shapely.readthedocs.io/en/latest/migration_pygeos.html).

Reading data

Create a GeoDataFrame called: sd_gdf that contains the data from the file /data/shared/tims/sdcounty_2020_fatal.geojson

How many rows and columns are in this GeoDataFrame?

Use the explore method to create an interactive map of the accident data

What are the column names (aka variable names, aka attribute names)?

CRS

Provide an explanation of what sd_gdf.crs reports. What is this attribute used for? What does the code mean

Explore the association between Alcohol and Day of the Week

Using groupby explore whether Alcohol is more prevalant in the weekend fatal accidents than the weekday fatal accidents.