Skip to content

Introduce st_join() before or within current Chapter 14 #44

Description

@mpjashby

Rationale

The downloadable report associated with current Chapter 14 uses st_join() to attach neighbourhood attributes to homicide points, but students have not previously been taught what a spatial join does. In the proposed chapter order, the next substantive use is not until current Chapter 15, so the report contains a forward dependency that students may be unable to understand or debug.

Suggested location

The preferred location is current Chapter 9, shortly after its explanation of left_join(). Students are already learning how tabular joins match rows using column values, so this provides a natural contrast: st_join() matches spatial features according to their locations.

If adding it to current Chapter 9 would overload that chapter, add a concise just-in-time explanation in current Chapter 14 before the example report.

Suggested content

  • Explain that st_join(x, y) retains the geometry and rows of x and adds attributes from spatial features in y that match spatially.
  • Contrast matching by location with left_join(), which matches values in columns.
  • Use a small point-in-polygon example relevant to crime locations and area boundaries.
  • Note that both objects need compatible coordinate reference systems.
  • Explain that unmatched features produce missing values and that multiple spatial matches can duplicate rows.
  • Show a simple validation step, such as counting unmatched rows and checking the resulting row count.
  • Add a cross-reference from the Chapter 14 report code to the explanation.

Completion criteria

  • st_join() is explained before it appears in the downloadable Chapter 14 report.
  • The explanation distinguishes spatial joins from attribute joins and covers common validation checks.
  • The report can be followed without relying on material from current Chapter 15.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions