R/data.coordinates2gridcellnumber.R

Defines functions data.coordinates2gridcellnumber

Documented in data.coordinates2gridcellnumber

data.coordinates2gridcellnumber <- function(grid, x,y){		
		valid.values <- which(is.na(grid$alt)==FALSE)
		valid.x <- grid$x[valid.values]
		valid.y <- grid$y[valid.values]

		test.x <- abs(valid.x - rep(x,length(valid.x)))
		lowest.value <- sort(test.x)[1]
		tocheck <- which(test.x == lowest.value)
		
		test.y <- abs(valid.y[tocheck] - rep(y, length(tocheck)))
		lowest.value <- sort(test.y)[1]
		found.y <- which(test.y == lowest.value)
	
		return(valid.values[tocheck[found.y]])
}

Try the phenmod package in your browser

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

phenmod documentation built on April 14, 2022, 5:08 p.m.