Lab 1 practice test#
This is a self-assessment on Lab 1 that you can fill out at home, to get a sense of how you perform and what future tests will look like (type and count of questions). It is not graded and you don’t hand anything in. Your final Lab 1 performance replaces the test result for Lab 1. The tests for the other labs will be written and proctored in class (see Tests).
How to use it:
Set a timer for 30 minutes. Work with pen and paper, as you would in a written test: no notebooks, no labs, no AI.
Write your answers in full sentences (or a few lines of code) before you open the solutions.
Each question has a point value. Compare your answer with the solution and give yourself partial credit if you got part of it. Treat the total as a rough guide only.
Whatever you could not answer is a pointer to what to review in the labs and readings.
21 points in total.
Questions#
Question 1 (3 p)
d is a DataFrame of the class survey with a column 'sw_r' (ratings 1–5). What type of object does each line return, and what does it contain?
d['sw_r']
d[['sw_r']]
d[d['sw_r'] >= 3]
Reveal solution
d['sw_r']: aSeriescontaining the column (1 p).d[['sw_r']]: aDataFramewith one column (1 p).d[d['sw_r'] >= 3]: aDataFramewith all columns, filtered to the rows (students) where the rating is 3 or higher (1 p).
A string selects a column, a list of strings selects columns as a DataFrame, and a boolean Series selects rows.
Question 2 (3 p)
A student runs zonal_stats on the subdivisions and stores the result in subdivisions, a GeoDataFrame whose index contains the subdivision codes (e.g., 'US-MA'). The new column is empty (all NaN), even though zs contains numbers. Why? How can you fix it?
zs = zonal_stats(subdivisions_reproj, raster_path, stats=['mean'])
subdivisions['amph_thr'] = pd.DataFrame(zs)['mean']
Reveal solution
zonal_statsreturns a list of dictionaries, one per polygon.pd.DataFrame(zs)therefore gets the default integer index (0, 1, 2, …) (1 p).When you assign a
Seriesto a column,pandasaligns it on the index labels. The integer labels don’t match the subdivision codes, so nothing matches and every value isNaN(1 p).Fix: give the
DataFramethe index of the polygons you used:pd.DataFrame(zs, index=subdivisions_reproj.index)(1 p).
Question 3 (3 p)
and (b): Which coordinate reference system would you pick for each task? Choose from: EPSG:4326, EPSG:6933, EPSG:3857, or a local UTM zone. Add a few words of justification. (1 p each)
Computing the area of every country in the world.
Storing a global dataset to share with other researchers.
You want to run
zonal_statswith country subdivisions in EPSG:4326 and a species richness raster in World Eckert IV. Which of the two layers would you reproject, and into which CRS? Why? (1 p)
Reveal solution
EPSG:6933. It is an equal-area projection, so areas computed from the polygons are proportional to the area on the ground (in m2). In EPSG:4326 the area comes out in degrees2 and is distorted away from the equator.
EPSG:4326 (latitude and longitude on WGS84), the standard for storing and sharing global data. GPS devices report positions in it.
Reproject the vector layer (the subdivisions) into the CRS of the raster (World Eckert IV, e.g., via its proj4 string). Rasters would have to be re-gridded (resampled), which loses information and is slow, whereas vector coordinates are floating-point numbers and stay precise.
Question 4 (3 p)
The raster and the boundary of Colombia are both in EPSG:4326, yet this code draws them in different parts of the figure. Why? How can you fix it?
fig, ax = plt.subplots()
ax.imshow(r)
colombia.plot(ax=ax, facecolor='none', edgecolor='black')
Reveal solution
Without an
extent,ax.imshowplaces the raster in pixel coordinates (0 to width, 0 to height), whilegeopandasplots the boundary in degrees.matplotlibknows nothing about coordinate reference systems (2 p).Fix: tell
imshowwhere the image belongs, using the bounds of the raster file:ax.imshow(r, extent=(xmin, xmax, ymin, ymax))(orextent=plotting_extent(r_file)). Mind the order:r_file.boundsreturnsxmin, ymin, xmax, ymax(1 p).
Question 5 (3 p)
Brown et al. (2015) argue that a map of species richness, like the one you made in Lab 1, is not a conservation plan. Pick two of the four lessons they draw from three decades of conservation planning. For each, explain in a sentence how taking it into account could change which places you would prioritize.
Reveal solution
Brown et al.’s four lessons:
Priority setting requires explicit and defensible objectives. Without them, we can’t tell whether protecting the highlighted places achieves anything in particular.
Conservation plans should prioritize actions, not places or species. Actions differ in their costs and probabilities of success.
Plans should consider economic, political and social constraints on actions. A place that is too costly or impossible to act on is a poor priority, however species-rich.
Plans should account for complementarity: the composition of species assemblages across sites. Protecting a second hotspot with the same species adds less than protecting a site that holds species not yet covered.
Give yourself 1 p for each lesson you named correctly and 0.5 p for each explanation of how it changes priorities (3 p total, capped).
Question 6 (3 p)
A lake offers recreational fishing. Anglers must buy a $20 permit for each day they fish, and together they fish 10,000 days per year.
A student says: “The total value of the fishing experience to anglers is $20 × 10,000 = $200,000 per year.” Is she right? Why or why not?
Reveal solution
No (1 p). $200,000 is what anglers pay (the permit sales), not what the fishing is worth to them.
Their benefit is their willingness to pay, and most anglers would have paid more than $20 for most of their days. The price only reflects the value of the last day fished (the marginal value) (1 p).
The difference between what anglers would be willing to pay and what they actually pay is the consumer surplus. The total value to anglers is therefore larger than $200,000 (1 p).
In the water example of Goulder & Kennedy (Fig. 2.1), sales are area II, while total value is the sum of areas I and II.
Question 7 (3 p)
Goulder & Kennedy link types of benefits to valuation methods. Each of the three benefits below is best measured with a different approach. Two approaches are named here: market prices and stated preference. Name the third approach yourself. Match each benefit to its approach, and say in a few words why. (1 p each)
The satisfaction that people derive from knowing that a wetland exists, even if they never visit it.
Recreational visits to a national park.
Timber harvested from a forest.
Reveal solution
Stated preference (e.g., contingent valuation). This existence value involves no behavior or purchase, so there is no “behavioral trail” to observe. Asking people may be the only way to estimate it.
Revealed preference (revealed expenditure methods, e.g., the travel cost method). Park visits are non-consumptive and entry fees (if any) understate their value. Visitors reveal what the visit is worth to them through what they spend to get there. (Stated preference can also be used for recreation, but the lab and reading emphasize the travel cost method.)
Market prices. Timber is a marketed good (a direct consumptive use). The market price is an indicator of the marginal value.
Where to go from here#
If a question was difficult, go back to the lab it came from: pandas indexing (Lab 1.2), geopandas and zonal_stats (Lab 1.3), coordinate reference systems (Lab 1.1 and Lab 1.3), and aligning rasters and vectors on a map (Lab 1.4).
Bring your questions to class.