Part 1: Adding columns to an attribute table
- Download and open the city council districts shapefile via Bytes of the Big Apple.
- Enter edit mode for the layer by going to Layer > Toggle Editing.
- Open the Field Calculator.
- Create a new field with name
area_sqft
, type Decimal number (real)
, length 15
, and precision 2
. Use the expression $area
to calculate the area.
- Confirm that the field was added to the attribute table.
- Do this again, but this time call the field
area_sqmi
and use the expression $area / (5280 * 5280)
to calculate the area in square miles.
- Exit edit mode.
Part 2: Counting points in polygons in QGIS
- Re-open the city council districts from the previous part if you closed it.
- Find the count of points in by city council district: go to Vector > Analysis Tools > Points in Polygon and ensure that the city council districts are selected for the polygon layer, Airbnb data for the points layer.
- Open the attribute table for the new shapefile. It should have a new column named
PNTCNT
. Is it NULL
for every feature? Why might this be, and how can you fix it?
- Fix the problem and leave the file open for the next part.
Part 3: Styling choropleths in QGIS
- Using the data from the previous part, style it using a Graduated style with the new
PNTCNT
column.
- Try a few classification schemes and look at the histogram for each.
Part 4: Normalizing data in QGIS
- Using the data from the previous part, style it using a Graduated style with the new
PNTCNT
column normalized to the area of the city council districts.
- To do this, create a new column using the Field Calculator and divide the count by the area in square miles. Use this new column to make a graduated style.
- Again, try a few classification schemes and look at the histogram for each.
Part 5: Style using expressions
- Download and open the AirBnB listing data for NYC via Inside AirBnB.
- Style the size of the markers based on the
price
attribute, dividing by a 100. Your expression should look like "price" / 100
.
- There are some very large prices we would like to hide for this map. Filter the layer to only show features where
price
is less than 2000.