Description Usage Details Value Note Author(s) See Also Examples
Get site-level data from a local NASIS database.
1 |
When multiple "site bedrock" entries are present, only the shallowest is returned by this function.
A dataframe.
This function currently works only on Windows.
Jay M. Skovlin and Dylan E. Beaudette
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | ## Not run:
## Example: export / convert DMS coordinates from NASIS and save to DD import file
# load required libraries
library(soilDB)
library(rgdal)
library(plyr)
# get site data from NASIS
s <- get_site_data_from_NASIS_db()
# keep only those pedons with real coordinates
good.idx <- which(!is.na(s$x))
s <- s[good.idx, ]
# investigate multiple datums:
table(s$datum, useNA='always')
## this is not universally appropriate!
# assume missing is NAD83
s$datum[is.na(s$datum)] <- 'NAD83'
# check: OK
table(s$datum, useNA='always')
# convert to NAD83
old.coords <- cbind(s$x, s$y)
# add temp colum for projection information, and fill with proj4 style info
s$proj4 <- rep(NA, times=nrow(s))
s$proj4 <- paste('+proj=longlat +datum=', s$datum, sep='')
# iterate over pedons, and convert to WGS84
new.coords <- ddply(s, 'peiid',
.progress='text', .fun=function(i) {
coordinates(i) <- ~ x + y
proj4string(i) <- CRS(i$proj4)
i.t <- spTransform(i, CRS('+proj=longlat +datum=WGS84'))
i.c <- as.matrix(coordinates(i.t))
return(data.frame(x.new=i.c[, 1], y.new=i.c[, 2]))
})
# merge in new coordinates
s <- join(s, new.coords)
# any changes?
summary(sqrt(apply((s[, c('x', 'y')] - s[, c('x.new', 'y.new')])^2, 1, sum)))
# save to update file for use with "Import of Standard WGS84 Georeference" calculation in NASIS
# note that this defines the coordinate source as "GPS", hence the last column of '1's.
std.coordinates.update.data <- unique(cbind(s[, c('siteiid', 'y.new', 'x.new')], 1))
# save to file
write.table(std.coordinates.update.data,
file='c:/data/sgeoref.txt', col.names=FALSE, row.names=FALSE, sep='|')
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.