Spatial Data is Special Data

HES 505 Fall 2022: Session 6

Matt Williamson

Space Exploration

Objectives

  • Articulate why we care about space

  • Describe elements of spatial data

  • Define a coordinate reference system and its importance

  • Describe several ways to load spatial data into R

  • Identify projections in R

Locations, Relations, and Understanding

  • Geography uses location to understand how social and physical processes give rise to the environment we experience

  • Geographic Information Systems provide a structure for storing, visualizing, and describing location data.

  • GeoComputation and GIScience integrate math, stats, and high-performance computing to move beyond description.

Location lets us ask:

  • Questions about geographic distribution

  • Questions about geographic interaction

  • Questions about geographic change

  • Questions about geographic association

  • Questions about causation?

Location vs. Place

  • Place: an area having unique physical and human characteristics interconnected with other places

  • Location: the actual position on the earth’s surface

  • Sense of Place: the emotions someone attaches to an area based on experiences

  • Place is location plus meaning

Describing Location

  • nominal: (potentially contested) place names

  • absolute: the physical location on the earth’s surface

Describing Absolute Locations

  • Coordinates: 2 or more measurements that specify location relative to a reference system
  • Cartesian coordinate system

  • origin (O) = the point at which both measurement systems intersect

  • Adaptable to multiple dimensions (e.g. z for altitude)

Cartesian Coordinate System

Locations on a Globe

  • The earth is not flat…

Latitude and Longitude

  • Global Reference Systems (GRS)

  • Graticule: the grid formed by the intersection of longitude and latitude

  • The graticule is based on an ellipsoid model of earth’s surface and contained in the datum

Global Reference Systems

The datum describes which ellipsoid to use and the precise relations between locations on earth’s surface and Cartesian coordinates

  • Geodetic datums (e.g., WGS84): distance from earth’s center of gravity

  • Local data (e.g., NAD83): better models for local variation in earth’s surface

The Earth is Not Flat

  • But maps, screens, and publications are…

  • Projections describe how the data should be translated to a flat surface

  • Rely on ‘developable surfaces’

Developable Surfaces

Projection necessarily induces some form of distortion (tearing, compression, or shearing(

Choosing Projections

  • Some projections minimize distortion of angle, area, or distance

  • Others attempt to avoid extreme distortion of any kind

  • Particularly challenging for raster data

Choosing Projections

  • Equal-area for thematic maps

  • Conformal for presentations

  • Mercator or equidistant for navigation and distance

Mapping Location in R

Data Types and R Packages

Data Types

  • Vector Data
    • Point features
    • Line features
    • Area features (polygons)
  • Raster Data
    • Spatially continuous field
    • Based on pixels (not points)

Mapping loaction: Coordinate Reference Systems

  • Includes: Datum, ellipsoid, units, and other information (e.g., False Easting, Central Meridian) to further map the projection to the GCS

  • Not all projections have/require all of the parameters

  • R stores these data in several formats (EPSG, Proj, and WKT)

  • Lots of projection info available at spatialreference.org

Mapping loaction: Coordinate Reference Systems

  • Primarily accessed using sf::st_crs() or terra::crs()
f <- rast(system.file("ex/meuse.tif", package="terra"))
nc <- st_read(system.file("shape/nc.shp", package="sf"))
st_crs(nc)
crs(nc)

Mapping location: Extent

  • Extent: The amount of the Earth’s surface represented by the mapped features

R has a very specific definition of extent: the rectangular region encompassed by the data

Using R to access the extent

  • Using st_bbox() from the sf package
nc.shp <- st_read(system.file("shape/nc.shp", package="sf")) 
Reading layer `nc' from data source 
  `/Library/Frameworks/R.framework/Versions/4.2/Resources/library/sf/shape/nc.shp' 
  using driver `ESRI Shapefile'
Simple feature collection with 100 features and 14 fields
Geometry type: MULTIPOLYGON
Dimension:     XY
Bounding box:  xmin: -84.32385 ymin: 33.88199 xmax: -75.45698 ymax: 36.58965
Geodetic CRS:  NAD27
meuse.rst <- rast(system.file("ex/meuse.tif", package="terra"))
st_bbox(nc.shp)
     xmin      ymin      xmax      ymax 
-84.32385  33.88199 -75.45698  36.58965 
st_bbox(meuse.rst)
  xmin   ymin   xmax   ymax 
178400 329400 181600 334000 

Using R to access the extent

  • Using ext() from the terra package
ext(nc.shp)
SpatExtent : -84.3238525390625, -75.4569778442383, 33.8819923400879, 36.5896492004395 (xmin, xmax, ymin, ymax)
ext(meuse.rst)
SpatExtent : 178400, 181600, 329400, 334000 (xmin, xmax, ymin, ymax)

Mapping location: Resolution

  • Resolution: the accuracy that the location and shape of a map’s features can be depicted

  • Minimum Mapping Unit: The minimum size and dimensions that can be reliably represented at a given map scale.

  • Map scale vs. scale of analysis

Mapping location: Resolution

Using R to access resolution

  • Thematically defined for vector datasets (check your metadata!!)

  • Using res() in terra

f <- rast(system.file("ex/meuse.tif", package="terra"))
res(f)
[1] 40 40

Recap

Today’s goals

  • Articulate why we care about space

  • Describe elements of spatial data

  • Define a coordinate reference system and its importance

  • Describe several ways to load spatial data into R

  • Identify projections in R