Setup an ODBC Connection to the Local NASIS Database

NASIS 6.2
2017-06-14

Introduction

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.

Open the ODBC Data Source Administrator

  1. Go to the Start Menu and search for 'ODBC'. See this page if you get lost.

  2. With the "User DSN" tab selected, create a new data source by clicking on the "Add..." button.
  1. Choose the second option: "SQL Server authentication...", **don't try and re-type these, just copy/paste*
  1. On the next screen, select "Nasis-local" as the default data base.

  2. Click "Next" and then "Finish" the finalize the connection.

  3. Close the ODBC control panel by clicking on 'OK'

Install Required Packages

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 RODBC and 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

An example R session

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.