Skip to content
Prev 18849 / 29559 Next

Area calculation workflow

It's probably easier to use area() on the raster in the first place,
and subset on that with your range of temperatures. You wear an
approximation with area() on longlat but probably no more than you
introduce by another route, and it's easy to test with simpler made up
objects.

(Closing polygons with lines from contours is hard)

library(raster)
## (nothing realistic about this)
r <- raster(volcano, xmn = 0, xmx = 10, ymn = 20, ymx = 40, crs =
"+proj=longlat")

## get longlat-approx cell areas, and subset on "temperatures" in the
range [110, 130]
sum(area(r)[][r[] > 110 & r[] < 130])
On Tue, Jul 16, 2013 at 10:28 PM, Mark Payne <markpayneatwork at gmail.com> wrote: