bio photo

View All Tutorials

Workshop:
spatial-data-management-series

View ALL Tutorial Series




Github


Blog.Roll

R Bloggers

Overview

About

This lesson covers the key spatial attributes that are needed to work with spatial data including: Coordinate Reference Systems (CRS), Extent and spatial resolution.

R Skill Level: Beginner - you’ve got the basics of R down.

Goals / Objectives

After completing this activity, you will:

  • Understand that there are necessary spatial metadata associated with and/or embedded in the data
  • Understand that there is potentially ancillary data associated with individual elements in vector data files (like NEON tower data (point), road (line), watershed (polygon)).

Things You’ll Need To Complete This Lesson

To complete this lesson you will need the most current version of R, and preferably, RStudio loaded on your computer.

Install R Packages

Download Data


Set Working Directory: This lesson assumes that you have set your working directory to the location of the downloaded and unzipped data subsets. An overview of setting the working directory in R can be found here..

R Script & Challenge Code: NEON data lessons often contain challenges that reinforce learned skills. If available, the code for challenge solutions is found in the downloadable R script of the entire lesson, available in the footer of each lesson page.

Spatial-Temporal Data & Data Management Lesson Series: This lesson is part of a lesson series introducing spatial data and data management in R . It is also part of a larger spatio-temporal Data Carpentry Workshop that includes working with
raster data in R , vector data in R and
tabular time series in R .


Additional Resources

Spatial Metadata

There are three core spatial metadata elements that are crucial to understand in order to effectively work with spatial data:

  • Coordinate Reference System (CRS),
  • Extent
  • Resolution

Spatial Extent

The spatial extent of a spatial object is just how much area does it cover. A map of Paris has a smaller spatial extent than a map of all of France.

Units

The units of the extent are defined by the coordinate system that the spatial data is in.

Extent in Vector Data

GRAPHIC FROM COLIN

Extent in Raster Data

The spatial extent of a raster, represents the x,y coordinates of the corners of the raster in geographic space. This information, in addition to the cell size or spatial resolution, tells the program how to place or render each pixel in 2 dimensional space. Tools like R, using supporting packages such as rgdal, and associated raster tools have functions that allow you to view and define the extent of a new raster.

# View the extent of the raster
DEM@extent

## Error in eval(expr, envir, enclos): object 'DEM' not found
The spatial resolution of a raster refers the size of each cell in meters. This size in turn relates to the area on the ground that the pixel represents.
If you double the extent value of a raster - the pixels will be stretched over the larger area making it look more "blury".

Calculating Raster Extent

To calculate the extent of a raster, we first need the bottom left x,y coordinate of the raster. In the case of the UTM coordinate system which is in meters, to calculate the raster’s extent, we can add the number of columns and rows to the x,y corner coordinate location of the raster, multiplied by the resolution (the pixel size) of the raster.

Let’s explore that next.


Get Lesson Code

(some browsers may require you to right click.)