R/diag.bathy.R

Defines functions diag.bathy

Documented in diag.bathy

diag.bathy=function(mat,coord=FALSE){ ## internal function for approximate diagonal calculation

	as.numeric(rownames(mat)) -> lon
	as.numeric(colnames(mat)) -> lat

	m=nrow(mat) # lon
	n=ncol(mat) # lat
	
	coord.m = round(seq(1,m,length.out=max(m,n)), 0)
	coord.n = round(seq(1,n,length.out=max(m,n)), 0)
	
	data.frame(lon[coord.m], lat[coord.n]) -> coord.tab
	names(coord.tab) <- c("lon","lat")
	
	dia=NULL
	for(i in 1:max(m,n)){
		dia = c(dia, mat[coord.m[i], coord.n[i]])
	}
	
	if(coord == FALSE) return(dia) else return(coord.tab)

}

Try the marmap package in your browser

Any scripts or data that you put into this service are public.

marmap documentation built on March 31, 2023, 6:59 p.m.