Reputation: 930
I want to plot the raster ,using code as follows:
library(raster)
tmp <- scan(what='')
'D:\temp\m2001EOS.tif'
ra<-raster(tmp)
plot(ra)
ra
attribution as follows:
class : RasterLayer
dimensions : 1941, 1832, 3555912 (nrow, ncol, ncell)
resolution : 981.8572, 981.8572 (x, y)
extent : 4723620, 6522382, 4203136, 6108921 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=aea +lat_1=25 +lat_2=47 +lat_0=0 +lon_0=105 +x_0=4000000 +y_0=0 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0
data source : D:\temp\m2001EOS.tif
names : m2001EOS
values : -32768, 32767 (min, max)
The plot is so wide that is not match xmin
and xmax
, but the range of height seem reasonable to ymin
and ymax
. Which parameter causes different patterns?
And how to adjust the box outline?
The example file is m2001EOS.tif
Upvotes: 1
Views: 1117
Reputation: 31452
Using the volcano data set, we can get a simple reproducible example which does not require downloading data from a remote link:
library(raster)
plot(raster(volcano))
When plotting rasters (using raster::plot
):
Given these two constraints, the need to fill the bounding box with blank areas follows as a direct consequence.
So how to avoid this? One way is to simply change the height to width ratio of the plot window or output file.
pdf(height = 4, width = 4)
plot(raster(volcano))
dev.off()
Even better is to use rasterVis::levelplot
for nicer plotting:
library(rasterVis)
levelplot(raster(volcano), margin = F)
Upvotes: 3