library(raster)
r1 <- brick(system.file("external/rlogo.grd", package="raster"))
plotRGB(r1)
png(filename = "boy.png",width=50, height=50)
x <- crop(r1, extent(0,50,0,50))
plotRGB(x)
dev.off()
Above code creates boy.png in my default working directory. The image is 50 pixels by 50 pixels.
- How can I make that image - 100 pixels by 100 pixels while keeping aspect ratio and DPI the same?
- In my
png(filename = "boy.png",width=50, height=50)
command I have to specify image size. Otherwise i get image of size 480 pixels by 480 pixels where cropped part of the image -x <- crop(r1, extent(0,50,0,50))
is blown in size. If in my png command i mention width as 100 and in my crop command if the image width is <100 then i get two white bands around my actual image(it seems that raster package fills extra space with white color). Is there a way to get image of exact size as mentioned in crop command but without specifying image width and height in png command?