Skip to content
Prev 20724 / 29559 Next

Iteratively subsample a rater and reassemble

Ok, so I think the way I described may work for what you are doing --
basically, make a raster where each pixel is the per-country
population value via ?subs linking the country code with the
population.  From that, you will have, for each pixel, an estimate for
the full country population, and a corresponding ACTUAL population for
each pixel, with which you can now do band math.

Given a raster of two countries A and B:

A A A B B B
A A A A B B
A A B B B B

And data.frame:
ID Population
A  100
B  200

A ?subs will return a raster:

100 100 100 200 200 200
100 100 100 100 200 200
100 100 200 200 200 200

A more brute-force (assuming you have enough memory) is to ?getValues
the entire raster, and convert it into a data.frame.  For small
rasters this is fine, for bigger rasters this is a more serious issue.

--j
On Mon, Mar 31, 2014 at 12:12 PM, Gordon Holtgrieve <gholt at uw.edu> wrote: