Does anyone know an efficient way to resample an image? I am currently trying to crop a large image and clip two regions from a shapefile. From this clipped image, I would like to increase the pixel density by a factor of 10. I would like to then mask this clipped and resampled image. Is there an efficient way to do this?
I am using an image with a resolution of 250m, and when I plot the .kml the pixels are nowhere close to the edges of my shapefile, so I found resampling and increasing the pixel density, then masking this image is the best way so far. The problem is the polygons I am clipping from are extremely far away from each other, so this means that right now the area in between has to all be resampled, and it is taking an extremely long time.
img <- crop(Canada,spdf) proj4string(img) <- CRS("+proj=lcc +ellps=GRS80 +lat_1=49 +lat_2=77 +lon_0=-95") factor <- .1 incol <- ncol(img) inrow <- nrow(img) resample_img <- raster(ncol=(incol/factor), nrow=(inrow/factor)) extent(resample_img) <- extent(img) final_img <- resample(img,resample_img,method="ngb") proj4string(maybe)<- CRS("+proj=lcc +ellps=GRS80 +lat_1=49 +lat_2=77 +lon_0=-95") final_img <- mask(final_img,spdf)