Skip to main content

Lab 3 — Street Bump

Adapt from https://pages.github.khoury.northeastern.edu/2500/2024F/lab/lab7.html

Very rough starting point at https://code.pyret.org/editor#share=1_Qa-ZGQF5j4LfMmv7pcSvbUt2DYQon5Y&v=dc8be4e

Introduction

In this lab, you’ll work with a simple representation of Boston’s “Street Bump” pothole-detection data. Each pothole is modeled as a record containing its zipcode, latitude, and longitude.

Problem 1

For this first problem, we'd like you to define a new table z02115 containing only rows whose zipcode field equals 02115. You can find the list of Boston's potholes in the potholes_2024.csv file, which you should load then filter through to find potholes that are found in the zipcode 02115. (Hint: the function filter-with may be helpful here!)

Problem 2

TODO: INTERPRETIVE QUESTION

Problem 3

Create a new table ordered-by-lat that contains all the rows from your z02115 table sorted by the "latitude" column in ascending order (so the southernmost points come first). Once you’ve built ordered-by-lat, define a constant LOWEST-LAT which extract the first row of the transformed table to identify which neighborhood has the lowest latitude.

Problem 4

Finally, you’ll enrich your z02115 table by adding a new "midpt" column that captures the average of each pothole’s latitude and longitude. First, define a helper function:

fun mid-point(row :: Row) -> Number:
doc: "calculates the midpoint of a pothole"
# IMPLEMENT HERE
end

Then, use build-column to attach "midpt" to z02115, producing a new table potholes-with-midpt where every row includes its computed midpoint.