This document describes how setup an ODBC link between a local NASIS database and R, so that pedon and DMU records can be queried with the soilDB package.
Go to the Start Menu and search for 'ODBC'. See this page if you get lost.
With the “User DSN” tab selected, create a new data source by clicking on the “Add…” button.
nasis_local, the data source description is optional.
XXXXXXis the full name of your local machine. It is usually on the outside of your computer somewhere, or can be accessed by right-clicking on the “My Computer” icon and then clicking on the “Properties” tab. It will look something like:
CASONORA00L354. When finished click “Next”.
Choose the second option: “SQL Server authentication…”, *don't try and re-type these, just copy/paste
On the next screen, select “Nasis-local” as the default data base.
Click “Next” and then “Finish” the finalize the connection.
Close the ODBC control panel by clicking on 'OK'
You will need to install a couple of packages before R is able to read data from the local NASIS database. This only has to be done once, usually the first time you open RStudio on your machine. Open RStudio (start menu, search for RStudio) and copy and paste the following lines into the R console. Press the enter key and wait: R will automatically download and install these packages. If this is the first time you have installed packages, you may notice that many more than the following two packages are being installed. This is normal– the
soilDB packages depend on many other related packages, which must be installed first.
# install packages (only first time) install.packages("RODBC", dep=TRUE) # stable version from CRAN + dependencies install.packages("soilDB", dep=TRUE) # stable version from CRAN + dependencies
After installing the above packages, add some sites/pedons into the selected set and try loading them into your R session.
# load required libraries library(soilDB) # fetch all pedons from the selected set in local NASIS database fp <- fetchNASIS() # make sketches of the first 10 pedons: par(mar=c(0,0,0,0)) plot(fp[1:10, ], name='hzname', label='taxonname')
Good job, that wasn't so hard. Now is a good time to check out some of the tutorials on the AQP website. Details on loading NASIS data into R can be found in this tutorial.