Intro to Vector Data in R

Creation supported by NEON, Data Carpentry, SESYNC, and iPlant Collaborative
Table of Contents

The data tutorials in this series cover how to open, work with and plot vector-format spatial data (points, lines and polygons) in R. Additional topics include working with spatial metadata (extent and coordinate reference system), working with spatial attributes and plotting data by attribute.

Data used in this series cover NEON Harvard Forest Field Site and are in shapefile and .csv formats.

Learning Objectives

After completing the series you will:

  • Vector 00:
    • Know the difference between point, line, and polygon vector elements.
    • Understand the differences between opening point, line and polygon shapefiles in R.
  • Vector 01:
    • Understand the components of a spatial object in R.
    • Be able to query shapefile attributes.
    • Be able to subset shapefiles using specific attribute values.
    • Know how to plot a shapefile, colored by unique attribute values.
  • Vector 02:
    • Be able to plot multiple shapefiles using base plot().
    • Be able to apply custom symbology to spatial objects in a plot in R.
    • Be able to customize a baseplot legend in R.
  • Vector 03:
    • Know how to identify the CRS of a spatial dataset.
    • Be familiar with geographic vs. projected coordinate reference systems.
    • Be familiar with the proj4 string format which is one format used used to store / reference the CRS of a spatial object.
  • Vector 04:
    • Be able to import .csv files containing x,y coordinate locations into R.
    • Know how to convert a .csv to a spatial object.
    • Understand how to project coordinate locations provided in a Geographic Coordinate System (Latitude, Longitude) to a projected coordinate system (UTM).
    • Be able to plot raster and vector data in the same plot to create a map.
  • Vector 05:
    • Be able to crop a raster to the extent of a vector layer.
    • Be able to extract values from raster that correspond to a vector file overlay.

Things You’ll Need To Complete This Series

Setup RStudio

To complete the tutorial series you will need an updated version of R and, preferably, RStudio installed on your computer.

R is a programming language that specializes in statistical computing. It is a powerful tool for exploratory data analysis. To interact with R, we strongly recommend RStudio, an interactive development environment (IDE).

Install R Packages

You can chose to install packages with each lesson or you can download all of the necessary R packages now.

  • raster: install.packages("raster")
  • rgdal: install.packages("rgdal")
  • sp: install.packages("sp")

More on Packages in R – Adapted from Software Carpentry.


Working with Vector Data in R Tutorial Series: This is part of a larger collection of spatio-temporal data tutorials. It is also part of a Data Carpentry workshop on using spatio-temporal in R. Other related series include: intro to spatio-temporal data and data management, working with raster time-series data in R, and working with tabular time series data in R .

Add new comment

CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
Find more series
mjones01
Dialog content.