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
Clip points to polygon shapefileOpen packages needed to use this snippet and the data.*
Project the data.
Plot the shapefile and dataset.
Notice that the puma data is global. Often clipping can be difficult to write out, but R lets you simply subset the puma data based on the US data:
Now you only have data for the US!
|
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
|