2

I'm trying to mask a raster with a ring polygon using the function raster::mask, but only recognizes the outer edges of the polygon, can anyone help me with this? I only need the pixels within the yellow area, but it returns pixel inside the outer edge of the polygon.

library(raster)

raster<-raster("my_raster_path")  
buffer<-shapefile("my_shapefile_path") #yellow buffer

output<-mask(raster, buffer)
writeRaster(output, "filename") #output grayscale raster

I only need the pixels within the yellow area

8
  • How about you divide the task in two steps? First the outer, then the inner clip?
    – Erik
    Commented May 22, 2019 at 14:33
  • Thanks Erik. How can I clip the inner section?
    – Claudia
    Commented May 22, 2019 at 14:36
  • I guess like the other operation, simply separate your mask into two parts.
    – Erik
    Commented May 22, 2019 at 14:37
  • can you post the code you are using?
    – GCGM
    Commented May 22, 2019 at 15:03
  • 1
    Can't do this without your data or something that shows the same problem.
    – Spacedman
    Commented May 22, 2019 at 17:16

0

Your Answer

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

Browse other questions tagged or ask your own question.