Assignments
Basics 1 (27 Sept.)
- In class: create a practice dataframe
- Create 4 vectors of 5 or more elements, 3 numeric and one grouping (character) variable
- Test vector calculations, such as addition, math functions, and stat functions
- Combine into a dataframe
- Find mean of the product of 2 numeric columns
- Find mean in different groups
- At home
- Load a large table of your own data into R, either from Excel or via an ascii file
- Or see the sample data link for table of Quercus records or Panama trees
- Try manipulations or calculations relevant to your interest...
- ... perhaps split into 2 (or more) dataframes by filtering on one column
- ... and find mean and SD of any numeric variable in each of the columns
Basics 2 (4 Oct.)
- In class
- Write a function to find \( \left( {x^n} \over n! \right) \) for any chosen x and n (note R function factorial
- Write a function to use a loop to sum over that previous function from 1 to N for any chosen x and N
- Debug so it stops after finishing each step through the loop
- Find the result for a single x and N = 1,2,3,4,5, store in a new vector, and graph vs. N
- At home
- Load data quercusPan-Mex.csv into R
- Plot all coordinates using R's basic plot function
- With function points color the points for a single species
- Likewise color the points for a single country
- Hint: Use function subset to extract data for a single species or country (or both)
- Write a function that calculates the range of latitude and longitude for any chose species
- Hint: Use function subset to extract data for a single species
- Hint: To return 2 numbers (range of lat and long), use the c function
Mapping in standard R (11 Oct.)
- In class
- Start a map with one polygon in a list, setting xlim and ylim to overall ranges
- Calculate distance between first two polygons in the list you mapped
- Write a loop through all polygons in one list
- Add each to a map
- Use polygon function to color each
- Repeat, but convert coordinates to UTM before graphing (with convUL)
- At home
- Make a map of Chicago towns (ChiTownCompact or ChiTown)
- Overlay streets and rivers
- Manipulate axis labels (hint: function axis)
- Add labels (hint: functions text, legend, mtext)
R shape files (18 Oct.)
- In class
- Load the GIS named chicago_illinois.water_coast
- Check the projection and coordinates
- Load and map
- Find the number of polygons (or lines)
- At home
- Locate shape files online (or if you have already)
- Load and explore
- Try rgdal: it requires external libraries GDAL and PROJ.4
R raster files (25 Oct.)
- In class
- Load the geotiff file named lcoi_99-00b.tif
- Find the coordinate system
- Extract a section around Chicago
- Count all land-use categories around Chicago
- Convert to lat-long (this takes several minutes, though)
- At home
- Overlay coastline from chicago_illinois.water_coast on land-use map around Chicago
- Overlay contour lines at 20-m intervals from srtm_19_04.tif
- Try converting the Chicago GIS (State Plane Zone)
"+proj=tmerc +lat_0=36.66666666666666 +lon_0=-88.33333333333333 +k=0.9999749999999999 +x_0=300000.0000000001 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192 +no_defs"
Spatial calculations (1 Nov.)
- Sample GIS data
- Illinois land use: lcoi_99-00b.tif
- Chicago towns: Municipalities.zip
- National Forests: S_USA.AdministrativeForest.zip
- US parks: ne_10m_parks_and_protected_lands.zip
- World parks: INTpol_RWB.zip
- US cities: citiesx010g.zip
- World cities: ne_10m_populated_places.zip
- Points in polygons
- Locate all cities and sum their population within one US National Forest
- Calculate population of one Chicago-area municipality by locating cities within
- Extract Illinois land use with one Chicago-area municipality
- Transformation: Matching coordinates, distance in degrees vs. kilometers
Distance calculations (8 Nov.)
- Sample GIS data (see 1 Nov list above)
- Distances or lengths
- Find nearest city to one national park (either US or world)
- Find cities within a given distance of a national park
- Sum length of railroad lines in one municipality or one National Forest
- Find distance of nearest rail line to one municipality
- Looping: all such calculations would be most useful if repeated for all parks etc.
Creating your own Spatial Class (15 Nov.)
- Use GPSVisualizer to create 4 polygons from somewhere interesting
- Combine them into a Spatial Class
- Create a map and find the polygon areas