Topic: Survey
Topic Description:
Functions for estimating elevation from topographic survey data.
File: topography/solvetopo.r
| View File Source | Download File | No help file available |
Function: rearrangeSurveyData
Function Description: rearrangeSurveyData
Takes a table of survey sightings with columns of x and y locations of two points, and converts it to the format required by solve.topo. The input table must have columns x1, y1, x2, and y2. The return value is a list consisting of two dataframes:- all points found in the input table, with an integer designation assigned to each. The designation is called pt.
- the second table matches the input table, but instead of x-y coordinates for the two points, only columns pt1 and pt2 are included to indicate the two points between which a sighting was taken.
Function Arguments:
| Argument | Default Value |
|---|---|
| inputtable |
Function Source:
rearrangeSurveyData=function(inputtable)
{
startpts=inputtable[,c('x1','y1')]
endpts=inputtable[,c('x2','y2')]
colnames(startpts)=colnames(endpts)=c('x','y')
allpt=unique(rbind(startpts,endpts))
allpt$pt=1:dim(allpt)[1]
m=match.dataframe(inputtable[,c('x1','y1')],allpt[,c('x','y')])
inputtable$pt1=allpt$pt[m]
m=match.dataframe(inputtable[,c('x2','y2')],allpt[,c('x','y')])
inputtable$pt2=allpt$pt[m]
outputcol=unique(c('pt1','pt2',colnames(inputtable)))
remove=outputcol %in% c('x1','y1','x2','y2')
result=subset(inputtable,select=outputcol[!remove])
return(list(allpt=allpt,IDtable=result))
}
{
startpts=inputtable[,c('x1','y1')]
endpts=inputtable[,c('x2','y2')]
colnames(startpts)=colnames(endpts)=c('x','y')
allpt=unique(rbind(startpts,endpts))
allpt$pt=1:dim(allpt)[1]
m=match.dataframe(inputtable[,c('x1','y1')],allpt[,c('x','y')])
inputtable$pt1=allpt$pt[m]
m=match.dataframe(inputtable[,c('x2','y2')],allpt[,c('x','y')])
inputtable$pt2=allpt$pt[m]
outputcol=unique(c('pt1','pt2',colnames(inputtable)))
remove=outputcol %in% c('x1','y1','x2','y2')
result=subset(inputtable,select=outputcol[!remove])
return(list(allpt=allpt,IDtable=result))
}