-4

I obtained a rectangular sort of image when I subset shapefile on the raster image. I want to get exact irregular shaped image so that I can proceed my classification to that particular area (B is my raster image):

boundryfile<-readOGR(dsn="E:\\FYP guide\\SUPARCO 2013\\Jamal Garhi",layer="Jamal Garhi")
B_crop<-crop(x=B,y=boundryfile)
0

R and raster crops to a bounding box so you will need to also mask to only retain the area of interest. Mask works by setting values inside or outside of a shape to a value usually NA in this context. See raster::mask command

Your Answer

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

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