[R] Sorting values within a raster

From: Sara Maxwell <smaxwell_at_ucsc.edu>
Date: Thu, 21 Apr 2011 12:23:26 -0700

I am working with a raster and want to take values assigned to each cell and sort them from largest to smallest, then cummulatively sum them together (in order from largest to smallest). I'll then be coding the individual cells such that the top 10% of the largest cell values can be visualize with one color, the next 10% with another and so on.

I have tried a number of schemes but am having trouble figuring out how to chose the maximum value, code it and re-search the raster for the next highest value without replacement. I am assuming this requires a loop, unless there is a function that will do this automatically.

Here is a sample dataset:

r <- raster(ncol=10, nrow=10)

values(r) <- runif(ncell(r))

Many thanks for any input,
Sara Maxwell

Sara M. Maxwell, Ph.D.
UC Santa Cruz

R-help_at_r-project.org 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. Received on Thu 21 Apr 2011 - 19:54:29 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 21 Apr 2011 - 20:40:32 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive