Here's what I came up with, thanks to Alex Brown and Roger for the solution:


#needs the maptools package to read ESRI grid
require(maptools)
#import the flow accumulation grid
basin.map <- readAsciiGrid("c:/temp/eno_fac.asc", colname="fac")
#split on unique fac cell values
areas <-split(basin.map$fac,basin.map$fac)
length(areas)
#count each occurence of fac value
cell_count<-sapply(areas, length)
#calculate each drainage area, original is 20 ft resolution, we want square
meters
basin_area <- cell_count * 20 * 20 * 0.09290304
#read the area into a dataframe
freqs<-as.data.frame(table(basin_area))
#rank the frequencies based on each unique occerence, note, ranks from 1 to
n
r<-rank(freqs$basin_area)
n<-length(r)
#determing the probability, n+1 insures there is no 100%, 1- reverses the
order so
#low drainage area gets high probability of exceedence
z<-cbind(Rank = r, PRank = 1-(r/(n+1)))
#attach the probability to the table, result is high prob of exceed is in
row with low drainage
#and low probabibility is in row with high drainage
freqs$rank<-z

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to