Skip to main content

Chapter exercise: What Is Geographic Data?

Points, Lines, Polygons, and Grids

This exercise goes with Chapter 11, What Is Geographic Data? It builds on the tmap exercise from Chapter 10. It should take you about one hour. Read this whole section before you start.

TipGet the exercise file

Download geographic-data-exercise.Rmd

Save it in a new folder called geographic-data-exercise inside your geog215 folder, open it in RStudio, and work through it from top to bottom. Everything on this page is also at the top of the file.

Purpose

Skills you’ll practice. By the end of this exercise you will be able to:

  1. Choose how to represent real-world entities (as points, lines, polygons, or a raster) for a map at a given scale.
  2. Tell continuous data from discrete objects, and spatial data from attributes, in an sf object.
  3. Find the geometry type, the number of features, and the number of vertices of a vector layer.
  4. Explain how generalization trades detail for size, and how it changes measurements like area.
  5. Treat a raster as a grid of cell values, and calculate cell counts, areas, and resolution.
  6. Save a layer as a GeoJSON file and a shapefile, and explain what each format keeps and loses.

Knowledge you’ll gain. You’ll work with New Zealand’s regions, its highest peaks, and an elevation grid of one of Auckland’s volcanoes, and see how the same place can be stored in very different ways.

Why this matters. Every layer you’ll download this semester, from the Census Bureau, NC OneMap, or an ArcGIS portal, is a model of the world that someone built by making choices: what to keep, how much detail, which file format. Understanding those choices tells you what a layer can and can’t answer, why two “county” layers give different areas, and why a file you emailed to a classmate won’t open. These are the questions you’ll ask of every data source in your final project.

Task

Work through Parts 1 to 7 in order, top to bottom. In each part:

  • Read the short explanation, then do each step marked with a bullet (•).
  • Wherever you see ___, replace it with the missing code before you run the chunk. A chunk with ___ in it won’t run.
  • Before you run each chunk, predict what it will return. Then run it and check.
  • Answer each question (Q1, Q2, …) in a sentence or two of Markdown, where it says Your answer here.
Part What you’ll do About
1 Set up your file and load the data 3 min
2 Data abstraction: choose a representation 10 min
3 The parts of vector data 12 min
4 Generalization and map scale 8 min
5 A raster is a grid of cell values 12 min
6 Geographic file formats 10 min
7 Reflect, knit, and turn in 5 min

Turn in your .Rmd file and your knitted .html file on Canvas.

Criteria for success

Use this checklist before you turn your work in. Each item matches a row of the rubric below.

Criterion Full credit Partial credit No credit
Knits (2 pts) Knits to HTML with no errors Knits, but some chunks have errors shown Doesn’t knit, or no HTML turned in
Code (5 pts) Every blank filled in correctly; every chunk returns what was asked Most blanks correct Many blanks missing or wrong
Abstraction table (2 pts) Every row has a sensible representation at both scales, with a reason Some rows missing reasons Not done
Questions (9 pts) Q1 to Q11 answered correctly, with numbers from the output and the right vocabulary Some answers missing or wrong Most answers missing
Style (1 pt) Pipe where asked, readable code, no install.packages() Several problems
Reflection (1 pt) All three answered Missing

What a good answer looks like. Here is a question, a weak answer, and a strong one.

Question: Should a map of North Carolina’s rivers store them as vector or raster data?

Weak answer: “Vector.”

Strong answer: “Vector lines. A river is a discrete object with a clear location, and we’d want attributes for each river, such as its name and length. A raster would store it as a staircase of cells, and at the scale of a state map most rivers would be narrower than one cell.”

The strong answer names the data model and the geometry, and explains the choice using the entity and the map’s scale.

IMPORTANT! Save often. Before you knit, choose Run > Restart R and Run All Chunks to make sure every chunk works from a fresh start.