In-class Exercises
Part 1: Modeling
In this part we will use the data we worked with in the previous part to make a simple model. We will attempt to make a model that can predict where there will be more pressure on renters due to Airbnb listings in their neighborhoods.
- Download today's data.
- In QGIS, open the shapefile in queens_airbnb_model.
- Using the field calculator, create two new fields. The new fields should scale each field using
scale_linear
.- First, med_income has a minimum value of 15474, maximum value of 151964, so we use this expression in the field calculator:
Add an s_ at the beginning of the new field name to indicate that it is scaled. In this case, med_income becomes s_income (since you can only use 10 characters in a name). s_income should be a decimal number field with length 10 and precision 8.scale_linear("med_income", 15474, 151964, 1, 0)
- Follow a similar process for n_airbnb (created when we calculated the Airbnb listings per tract):
You'll need to find the minimum and maximum values for n_airbnb. Make the resulting field s_airbnb, also a decimal number with length 10 and precision 8.scale_linear("n_airbnb", minimum points, maximum points, 0, 1)
- First, med_income has a minimum value of 15474, maximum value of 151964, so we use this expression in the field calculator:
- Create a graduated style for the tracts. For the column expression, add each of the scaled fields (s_airbnb, s_renters, s_income) together.
Part 2: Changing properties with CartoCSS
- Upload the VNP14IMGTDL_NRT_Global_24h shapefile from today's data to Carto. You can just use the zip file without unzipping it. These are fires detected over a 24 hour period, retrieved Oct 11, 2019 from FIRMS.
- Open the CartoCSS documentation.
- Make a map with the data and style the points.
- Using CartoCSS:
- Make the markers 5 pixels wide.
- Give the markers an outline 2 pixels wide.
- Give the fill and stroke of the markers different colors.
Part 3: CartoCSS Zoom Conditions
- Make your markers 5 pixels wide below zoom level 8.
- Make your markers 15 pixels wide above or at zoom level 8.
Part 4: CartoCSS Attribute Conditions
- Make your markers a different color when the daynight is D.