Saturday 19 January 2019

resampling - Resample binary raster to give *proportion* within new cell window


I would like to go from a binary raster of forest/non-forest at 30m resolution to a raster at 240m resolution with the value of each cell being the proportion of that cell forested - i.e. the data values for the 240m cells would go from 0 (where all cells in the 30m raster were zero/non-forest) through 0.5 (where half the 30m cells were forest, half were non-forest) to 1 (where all cells in the 30m raster were forested).


Although it is has been suggested not to use bilinear interpolation on discrete data, as far as I can tell the result with binary 0/1 data would be to give an average value (i.e. a proportion between 1 and 0). Is this a sensible way to do it, or is there a better method?


I can use Arc, QGIS and Idrisi.



Answer




Use Block statistics.


This works like Focal statistics by computing a statistical summary (such as the mean you desired) within a specified neighborhood of cells (such as an 8 by 8 square, where 8 = 240 m / 30 m), except it performs this only for a regular subdivision of the grid, rather than with a set of overlapping neighborhoods, one at each cell.


You can also make use of Focal statistics if you really want to: after computing the focal mean over 8 by 8 squares, resample to a 240 m grid using nearest neighbor resampling. When the grids are registered to one another (i.e., they have the same origin) this should give the same result as block statistics. (I won't guarantee that: some arbitrary choices have to be made when new cell centers coincide with old cell corners--as they will here--and, if different committees coded the two procedures, they may have made different choices: little in ArcGIS is truly consistent, I'm afraid.)


Another approach is to create a grid of zones, one zone per square where an average is desired, and perform a zonal summary as a grid. The zones can be computed mathematically from grids of row and column coordinates (by means of the floor or int function, by reclassification, or by joining a suitable table to the attribute table).


I will close by remarking that bilinear interpolation, although it will indeed yield values in the range 0..1, is not what you want: it works by finding at most four original (30 m) grid cells surrounding the center of a new (240 m) cell and interpolating only their values. As such, it will overlook the other 8*8 - 4 = 60 original cells falling within each new block. I illustrate bilinear interpolation at http://www.quantdec.com/SYSEN597/GTKAV/section9/map_algebra.htm: the discussion begins near the middle of the page.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...