1

I've been trying to figure out a way to pre-process a single-band thematic raster dataset (e.g., land cover) to produce a multi-band raster of proportional cover.

For example, consider a land cover dataset with two land cover types: water and land.

What I would like is to calculate for each cell the proportional coverage by a given land cover type within some distance from the center of that cell.

The final product would be a 2-band raster where band 1 is proportional cover by water, and band 2 is proportional cover by land.

You can conceptualize this as a raster representing the output of a moving window exercise.

The window is a buffer of a given radius, and the centroid of the buffer is the center of the target cell.

The target cell is assigned the proportional cover by the land cover type, then the window moves to the next cell and repeats the process.

The full process would calculate a raster band for each land cover type in the dataset.

I've yet to figure out an efficient workflow for this; my solutions have all involved iteration (for loops) in R, which takes an absolute eternity for large raster datasets.

Is there a more efficient approach, preferably using ArcGIS or R?

  • Do you want the focal function from the R raster package? It does moving window evaluation of any user-supplied function. – Spacedman Apr 3 '17 at 22:31
  • That seems promising! (And goes to show you that, as familiar as you may be with R functionality, there's almost always a function out there to help you.) The downside of focal is that it seems to assume a matrix (analogous to a square buffer), and I'm looking for a circular buffer. I suppose that I could fudge this by creating a matrix of weights such that cells of the weight matrix within some maximum Euclidean distance from the center are equal to 1 and all others are 0, but that's an extra layer of code; I'd prefer to have something more elegant for demonstration and teaching purposes. – Garrett Street Apr 4 '17 at 19:34
  • @GarrettStreet I think a simple draw would be very helpful for your question! I don't realize how you wish a circular buffer would interact with square cells from the raster layer. Because some raster cells won't be all entirely inside the circular buffer. – Guzmán Apr 5 '17 at 15:00
  • The focalWeight function will make that window weight matrix for you, and take a radius in coordinate system units! – Spacedman Apr 5 '17 at 15:01
  • Thank you one and all for the insight! My student and I will be pursuing this line of thought shortly, and once we have sufficiently efficient code, we will share it here! – Garrett Street Apr 13 '17 at 19:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.