I have an image and i want to plot only 100*100 square with left hand bottom corner at 0,0. when i use below commands. Why do i get a white space around my cropped image? how can i avoid it and ensure that I get exact 100*100 image?
If you want to repeat my example, you can use any image on line 1 (provided that the image is bigger than 100*100 pixels)
r <- raster("C:/Users/nnnn/Desktop/geo.jpg")
vector= getValues(r)
plot(r)
r
par(mar=c(0,0,0,0))
par(oma=c(0,0,0,0))
par(mai=c(0,0,0,0))
par(omi=c(0,0,0,0))
plot(r,xlim=c(0,100),ylim=c(0,100),legend=FALSE,axes=FALSE)
Aspect ratios are normally maintained for maps. You can use width/height when plotting to a file. You can resize the standard device manually, but you can also do this:
library(raster)
r <- raster(nrow=240, ncol=320)
values(r) <- 1:ncell(r)
dev.new(height=0.91*nrow(r)/50, width=1.09*ncol(r)/50)
plot(r, legend=FALSE)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With