0

I have a raster (say r) and a polygon shapefile (say s, containing many polygons). I want to convert the pixelated r to mean of s boundaries. And I need these boundary means as another raster file.

What I have now is the extract function:

rmean <- extract(r,s,fun=mean,df=TRUE)

but, I am not able to convert this into a raster.

0

1 Answer 1

2

Assign the values to the polygons and then rasterise the polygons on that value.

Using polys and r from example(extract):

> polys$r = extract(r, polys, fun=mean)
> rp = rasterize(polys, r, "r")
> plot(rp)

enter image description here

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.