Setup ODBC Connection to Local NASIS

2019-01-15

Introduction

This document describes how to setup an ODBC link between R and the local NASIS database. See Chapter 2 from the Statistics for Soil Scientists training for a demonstration.

Open the ODBC Data Source Administrator

  1. Go to the Start Menu and search for 'ODBC'. See this page if you get lost. Select the 64bit ODBC application if you are using Windows 10. It should look like this:
  1. 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.
  1. Click "Next" and then "Finish" the finalize the connection.

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

Optionally Install Required Packages

You will need to install the RODBC and soilDB packages if not present. You can check by trying to load either of these packages at the console. Or, install using the commands below if you are unsure.

# stable version from CRAN + dependencies
install.packages("RODBC", dep=TRUE)

# stable version from CRAN + dependencies
install.packages("soilDB", dep=TRUE)

# latest version, required for Windows 10
remotes::install_github("ncss-tech/soilDB", dependencies=FALSE, upgrade=FALSE, build=FALSE)

An example R session

After installing the above packages, add some sites+pedons or components 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
x <- fetchNASIS(from='pedons')

# make sketches of the first 10 pedons
par(mar=c(0,0,0,0))
plot(x[1:pmin(length(x), 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.