NEON EDUCATION bio photo

NEON EDUCATION

Devoted to open data and open source in science and education.

View All Tutorials

Tags

LiDAR (7)
R programming (51)
Remote Sensing (12)
Data Visualization (4)
Hyperspectral Remote Sensing (7)
Hierarchical Data Formats (HDF5) (9)
Spatial Data & GIS (18)
Time Series (15)
Phenology (7)
Raster Data (8)
Vector Data (6)
Metadata (1)
Git & GitHub (6)
(1) (1)

Tutorial by R Package

dplyr (7)
ggplot2 (17)
h5py (1)
lubridate (time series) (6)
maps (1)
maptools (2)
plyr (2)
raster (26)
rasterVis (raster time series) (3)
rgdal (GIS) (22)
rgeos (3)
rhdf5 (11)
sp (5)
scales (4)
gridExtra (4)
ggtheme (0)
grid (2)
reshape2 (3)
plotly (5)

View ALL Tutorial Series




Twitter Youtube Github


Blog.Roll

R Bloggers
Date(s): Apr 12 - Apr 13, 2016

Things You’ll Need To For The Workshop

To participate in this workshop, you will need:

  • A laptop with the current version of R, and preferably RStudio, loaded.
  • An up-to-date web browser.

For step-by-step details on installing or setting up R or RStudio in Mac, PC, or Linux Operating Systems, please see the details at the bottom of this page.

If you already have R & RStudio installed on your laptop, please be sure that you are running the most current version of RStudio, R and all packages that we’ll be using in the workshop (listed below).

Download Data

To be prepared for this workshop, please download the following files in advance:

Download NEON Teaching Data Subset: Site Layout Shapefiles

These vector data provide information on the site characterization and infrastructure at the National Ecological Observatory Network’s Harvard Forest field site. The Harvard Forest shapefiles are from the Harvard Forest GIS & Map archives. US Country and State Boundary layers are from the US Census Bureau.

Download NEON Teaching Data Subset: Airborne Remote Sensing Data

The LiDAR and imagery data used to create this raster teaching data subset were collected over the National Ecological Observatory Network’s Harvard Forest and San Joaquin Experimental Range field sites and processed at NEON headquarters. The entire dataset can be accessed by request from the NEON Airborne Data Request Page on the NEON website.

Download NEON Teaching Data Subset: Landsat-derived NDVI raster files

The imagery data used to create this raster teaching data subset were collected over the National Ecological Observatory Network’s Harvard Forest and San Joaquin Experimental Range field sites.
The imagery was created by the U.S. Geological Survey (USGS) using a multispectral scanner on a Landsat Satellite. The data files are Geographic Tagged Image-File Format (GeoTIFF).

Optional: Download these global boundary files if you wish to follow along with the Intro to Coordinate Reference System Lesson. NOTE: Some of the contents of this code is not explicitly taught in the workshop. It is used to demonstrate differences between different CRS’ and to provide code examples for those who may be interested in mapping using GGPLOT in the future.

Download “land” - Natural Earth Global Continent Boundary Layer Download all Graticules - Natural Earth Global Graticules Layer

Set Working Directory

Once you have downloaded the data, set the R working directory to the uncompressed files. View complete directions and images of the R working directory setup here.


Install R Packages

You can chose to install each package individually if you already have some installed.

  • raster: install.packages("raster")
  • rasterVis: install.packages("rasterVis")
  • ggplot2: install.packages("ggplot2")
  • sp: install.packages("sp")
  • rgeos: install.packages ("rgeos")
  • rgdal (Windows): install.packages("rgdal")
  • rgdal (Mac): install.packages("rgdal",configure.args="--with-proj-include=/Library/Frameworks/PROJ.framework/unix/include --with-gdal-config=/Library/Frameworks/GDAL.framework/unix/bin/gdal-config --with-proj-lib=/Library/Frameworks/PROJ.framework/unix/lib")

GDAL installation for MAC

You may need to install GDAL in order for rgdal to work properly. Click here to watch a video on installing GDAL using homebrew on your Mac. Or, you can visit this link to install GDAL 1.11 complete.

Optional: The metadata tutorial, which includes a section on the Ecological Metadata Language (EML) is presented with a focus on the conceptual understanding of metadata and includes a demonstration of the eml package in R. If you wish to follow along with the code, please install the following:

  • devtools: install.packages("devtools")
  • eml: install_github("ropensci/EML", build=FALSE, dependencies=c("DEPENDS", "IMPORTS"))

NOTE: You have to run the devtools package (library(devtools)) first, and then install_github() will work. The eml package is under development which is why the install occurs from GitHub and not CRAN!

Make Sure R Packages Are Current

In RStudio, you can go to Tools --> Check for package updates to update already installed packages on your computer! Or, you can use update.packages() to update all packages that are installed in R automatically.

Workshop Instructors

Please get in touch with the instructors prior to the workshop with any questions.

#WorkWithData Hashtag

Please tweet using the hashtag #WorkWithData during this workshop!

Workshop Schedule

Please note that the schedule listed below may change depending upon the pace of the workshop!

Day One

Time Topic
8:00 Please come early if you have any setup or installation problems
9:00 Geospatial Data Management - Intro to Geospatial Concepts
  Answer a Spatio-temporal Research Question with Data - Where to Start?
  Data Management: Spatial Data Formats
  Data about Data – Intro to Metadata Formats & Structure
10:30 ——— BREAK ———
10:45 Data Management: Coordinate Reference Systems
12:00 - 1:00 ——— Lunch ———
1:00 Vector Data in R
  Open and Plot Shapefiles in R - Getting Started with Point, Line and Polygon Vector Data
  Explore Shapefile Attributes & Plot Shapefile Objects by Attribute Value in R
  Plot Multiple Shapefiles and Create Custom Legends in Base Plot in R
2:30 ——— BREAK ———
2:45 Vector Data in R, continued
  When Vector Data Don’t Line Up - Handling Spatial Projection & CRS in R
  Convert from .csv to a Shapefile in R
4:15 Wrap-Up Day 1

Day Two

Time Topic
9:00 Questions From Day One
9:15 Getting Started with Raster Data in R
  Intro to Raster Data in R
  Plot Raster Data in R
10:30 ——— BREAK ———
10:45 Getting Started with Raster Data in R, continued
  When Rasters Don’t Line Up - Reproject Raster Data in R
  Raster Calculations in R - Subtract One Raster from Another and Extract Pixel Values For Defined Locations
  Crop Raster Data and Extract Summary Pixels Values From Rasters in R
12:00 - 1:00 ——— Lunch ———
1:00 Multi-band Raster & Raster Time Series Data in R
  Work With Multi-Band Rasters - Image Data in R
  Raster Time Series Data in R
  Plot Raster Time Series Data in R Using RasterVis and Levelplot
  Extract NDVI Summary Values from a Raster Time Series
2:30 ——— BREAK ———
2:45 Multi-band Raster & Raster Time Series Data in R, continued
4:15 Wrap-Up Day Two!

Collaborative Note Taking

Throughout the course, we will use the Etherpad, to share links and take group notes about various topics.


Additional Set Up Information

Install R & R Studio

To participate in the workshop, we recommend that you come with R and RStudio installed. 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).

If You Don’t Have R or Rstudio Installed - Please Follow These Instructions:

If You Already Have R & RStudio Installed – Please Update

If you already have R & RStudio installed on your laptop, please be sure that you are running the most current version of R-Studio, R and all packages that we’ll be using in the workshop (listed below).

Windows R / RStudio Setup

Once R and R studio are installed, open RStudio to make sure it works and you don’t get any error messages.

MAC R / RStudio Setup

  • If your Mac is set up for UiO use, you can install R from Managed Software Center

  • Go to CRAN and click on Download R for (Mac) OS X
  • Select the .pkg file for the version of OS X that you have and the file will download.
  • Double click on the file that was downloaded and R will install
  • Go to the RStudio Download page
  • Under Installers select RStudio 0.98.1103 - Mac OS X 10.6+ (64-bit) to download it.
  • Once it’s downloaded, double click the file to install it

Once R and R studio are installed, open RStudio to make sure it works and you don’t get any error messages.

Linux R / RStudio Setup

  • R is available through most Linux package managers. You can download the binary files for your distribution from CRAN. Or you can use your package manager (e.g. for Debian/Ubuntu run sudo apt-get install r-base and for Fedora run sudo yum install R).
  • To install RStudi, go to the RStudio Download page
  • Under Installers select the version for your distribution.
  • Once it’s downloaded, double click the file to install it

Once R and R studio are installed, open RStudio to make sure it works and you don’t get any error messages.


Set R Working Directory

1) Download Data

First, download the data linked to from the blue buttons in the grey box above.

  • NEON Teaching Data Subset: Site Layout Shapefiles
  • NEON Teaching Data Subset: Airborne Remote Sensing Data
  • NEON Teaching Data Subset: Landsat NDVI

After clicking on the Download Data button, the data will automatically download to the computer.

Note: If you choose to download the optional data do this at the same time and include those files in the working directory that we are setting up here.

2) Locate .zip file

Second, find the downloaded .zip file. Many browsers default to downloading to the Downloads directory on your computer. Note: You may have previously specified a specific directory (folder) for files downloaded from the internet, if so, the .zip file will download there.

Screenshot of the Data that you should download prior to the workshop. Source: National Ecological Observatory Network (NEON)

3) Move to data directory

Third, create a directory (folder) called data within the Documents directory on your computer. Move the data files to this data directory.

4) Unzip/uncompress

Fourth, we need to unzip/uncompress the file so that the data files can be accessed. Use your favorite tool that can unpackage/open .zip files (e.g., winzip, Archive Utility, etc). The files will now be accessible in three directories:

  • NEON-DS-Airborne-Remote-Sensing
  • NEON-DS-Landsat-NDVI
  • NEON-DS-Site-Layout-Files

These directories contain all of the subdirectories and files that we will use in this workshop.

</b> Screenshot showing all directoires needed for the workshop. If you choose to set up the directories differently you will need to adjust the file paths used in the lessons as necessary. Source: National Ecological Observatory Network (NEON)

We will set up an RStudio project within this working directory. Read more about R-Studio projects, here. In RStudio, your working directory space will look like this:

Your working directory in RStudio should look like the above image.