23 April 2015

Setup an ODBC Connection to the Local NASIS Database

NASIS 6.2
2015-04-23
DEB

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.

    • Select the “SQL Server Native Client” driver.
    • Name the data source nasis_local, the data source description is optional.
    • The server location is XXXXXX\NASISSQLEXPRESS, where XXXXXX is 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”.
  3. Choose the second option: “SQL Server authentication…”, *don't try and re-type these, just copy/paste

    • login: NASISSQLRO
    • password: nasisRe@d0n1y
  4. On the next screen, select “Nasis-local” as the default data base.

  5. Click “Next” and then “Finish” the finalize the connection.

  6. 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.


This document is based on aqp version and soilDB version .