How to define projections and reproject spatial dataSeptember 30, 2016This R Tip uses code that was modified from homework assignments for the graduate class, Spatial Ecology For/FW 870 at Michigan State University. When plotting spatial data on a map, your shapefile and spatial occurrence data must have the same map projection or your map will appear distorted. Map projections account for the spheroid shape of the earth when projecting data onto a flat (map) surface. One of the most common projections is WGS 1984 (World Geodetic Survey 1984) using the WGS 1984 spheroid. This projection uses certain latitudinal and longitudinal coordinates to link a spheroid to a portion of the earth’s surface.
To find the projection of a raster or shapefile, you can use the command
The projection for the Oregon shapefile is GRS80. We can change the projection to match some data that we would like to plot over the Oregon shapefile. For example, we might like to plot spotted owl occurrences in Oregon. We need to check the projection of spotted owl data and change the projection of the owl data so that it matches the shapefile. To do this, we first define the projection of the owl data.
We then can reproject the spotted owl data by copying and pasting the projection output from the command
Now we can plot the spotted owl occurrences over the Oregon shapefile.
0 Comments
R Tip: Creating BoxplotsAnonymousSeptember 28, 2016This R tip is modified from http://www.statmethods.net/graphs/boxplot.html The following data is from a fungicide treatment experiment. 4 different models (Y, M, L, C) were used to describe the disease progress of 6 different treatments R2 values were used to determine which model (across all treatment types) should be used to compare the disease progress of the 6 treatments Boxplots were used to compare the model R2 values quickly
Setting graph axis limits and expanding plotting region in ggplot2Laura TwardochlebSeptember 14, 2016I demonstrate how to change axis limits and expand the plotting region in ggplot2, so that the plot origin lines up with the axis limits in a bar graph. The default graphic settings in ggplot2 produce bar graphs with the origin offset from the limits of the plotting region. We can visualize this using the built in “cars” dataset:
Above you can see that there is a gap between the plotting region on the lower y-axis and the origin (y=0). However, this graph will be more aesthetically pleasing and easier to read if the axis limits and plotting region both begin at the origin. To change this, we can add one line of code to change the limits of the y-axis and expand the plotting region to begin at the origin (y=0).
Here, I used
|
Spatial Ecology @ MSUClick on "Category" below to search for R code compiled by the Zarnetske Spatial & Community Ecology Lab and students in MSU's Spatial Ecology graduate course (FOR870/FW870) Category
All
Archive
October 2016
|