Skip to content

Commit

Permalink
edit lesson 02
Browse files Browse the repository at this point in the history
  • Loading branch information
Taylor Nelsen committed Jun 2, 2020
1 parent 30e1ab9 commit 4aef98b
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions 02-multispectral-data-extraction.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,23 @@ Zonal statics is like using the shapefile just created as a cookie cutter for th

Often in a research setting there are many uniform experimental units that are being measured. This example show how to create and extract data from a uniform set of experimental plots - in this case of wheat and triticale - with an R script in QGIS.

For this section to work, make sure you have the geosphere, rgdal, raster, and rgeos packages installed in R.
+ For ease of access, open the "package_install.R" file in the "Drone-Data-in_Agricultural-Research-data" folder
+ Run the entire script by pressing the run button at the top (<kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Enter</kbd>)

1. Setup new raster layer

> ### Challenge
>
> Add the raster layer "Davis_4l10l18_index_grvi.tif" in the downloaded "Drone-Data-in_Agricultural-Research-data" to the project. Zoom to the newly added layer.
2. Create a new shapefile layer
2. Re-project the raster layer
+ Check the projection of your raster file, if it is not in latitude and longitude (EPSG: 4326) then reproject it so that it is in latitude and longitude.
+ Make sure the raster layer "Davis_4l10l18_index_grvi" is highlighted and then navigate to "Raster" > "Projections" > "Warp (Reproject)"
![](img/reproject.png)
+ Change the "Target CRS" to EPSG:4326 – WGS 84
+ Click "Run" to reproject the image
![](img/warp-tool.png)
+ Close the processing window when it is done running

3. Create a shapefile to set the origin points of your trial. This is used to calculate the angle the field is at the distance the plots are from each other.
Expand All @@ -119,28 +125,30 @@ Often in a research setting there are many uniform experimental units that are b
+ Choose "Point" as the geometry
+ Make sure the CRS is ESPG: 4326 – WGS 84
+ Click `OK` to create the blank shapefile
![](img/pt-shp.png)

4. Set the origin points.
+ Toggle editing on the shapefile just created.
+ Choose the "Add Point Feature" tool (<kbd>Ctrl</kbd> + <kbd>.</kbd>)
![](img/add-pt-feature.png)
+ Add 3 points as follows:
+ plot 101 (the bottom left corner of your trial) should have id = 1
+ the bottom right corner should have id = 2
+ the top left corner should have id = 3
+ Do not include fill rows or data you do not want to extract
+ Toggle editing off to save
![](img/new-pts.png)

5. Check that the "Processing R" plugin is installed
+ Navigate to: "Plugins" > "Manage and Install Plugins…"
+ Finds "Processing R Provider" by scrolling or searching
+ Click the plugin and press "Install plugin" if the plugin is not already installed
![](img/processing-R-plugin.png)

6. The first time you do this, save the "smallPlotTrial.rsx" file in your corresponding directory:
C:\Users\UserName\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\processing_r\builtin_scripts

7. Make sure you have the geosphere, rgdal, raster, and rgeos packages installed in R.
+ For ease of access, open the "package_install.R" file in the "Drone-Data-in_Agricultural-Research-data" folder
+ Run the entire script by pressing the run button at the top (<kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Enter</kbd>)
6. Open an R script in QGIS
+ Click the R icon and "Create New R Script..." in the `Processing Toolbox`
+ Open the "small_plot_trial_extraction_0.0.2.rsx" file in the downloaded "Drone-Data-in_Agricultural-Research-data/R_scripts"
+ Click "Save As.." to save the script into the "QGIS3\profiles\default\processing\rscripts" folder so that the script can always be used in QGIS3 (otherwise wlcik the play button to execute)

8. Restart QGIS to load new script and plugin

Expand All @@ -154,6 +162,7 @@ C:\Users\UserName\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\pro
+ The default is for rectangular plots but if you want circular plots unchceck the checkbox next to rectangular
+ Click "Run"
+ Close the window when the algorithm is finished processing.

11. Save the shapefile
+ Right click the Output layer that was created then "Export" > "Save Feature As…"
+ Choose "ESRI Shapefile" as the output format
Expand Down
Binary file modified example_data/origin_pts.shp
Binary file not shown.
Binary file added img/Screenshot 2020-06-01 20.31.53.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/add-pt-feature.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/new-pts.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/processing-R-plugin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/pt-shp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/reproject.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/warp-tool.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4aef98b

Please sign in to comment.