[R-sig-Geo] Percentage of forest cover in a set radius for each raster cell

Jeremy Larroque larroque.jeremy at gmail.com
Sun Jan 24 21:58:34 CET 2016


Dear list members,



I have a forest layer and an empty raster. I would like to compute for each
raster cell the percentage of forest in a set radius around the center of
the cell.

I used the option “getCover” of the function rasterize but it only returns
the fraction of each grid cell that is covered by the polygons of forest.



Is there a way to do that in R?



The forest data can be downloaded here:
https://drive.google.com/folderview?id=0Bwf27qBU9Q1ONGpxSHFIbE9xRkk&usp=sharing



library(raster)

library(rgdal)



# forest data

forest <- readOGR(dsn = path1, layer = "foretze")



# raster set

Xmin <- c(795800)

Xmax <- c(840200)

Ymin <- c(2143600)

Ymax <- c(2186900)

rr <- raster(nrows=866, ncols=888, crs=CRS("+init=epsg:27572"), xmn=Xmin,
xmx=Xmax, ymn=Ymin, ymx=Ymax)



pforest <- rasterize(forest, rr, getCover=T)





Many thanks!



Jeremy

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list