Sunday, 1 March 2015

r - raster::plot() plotting raster too small- is there an alternative on ggplot?


I am trying to plot this raster on R. The object is quite big, but when plotting it using the raster::plot() function, I obtain a very tiny image, as attached.


The code I use to produce it is the following:


r <- raster::raster("MOD13Q1_2000-02-18.250m_16_days_NDVI.tif")
r <- setMinMax(r)
raster::plot(r)


I tried to set xlim limits, with no success. I then tried to move to ggplot2, as an alternative (following here), but I obtain the following


ggplot(r) + geom_tile(aes(fill=value))
Error: ggplot2 doesn't know how to deal with data of class RasterLayer

I found around that, to plot raster objects with ggplot(), I should first convert it into a data.frame. However, as my object is quite big (about 55million obs.), that would be very inefficient. I am then stuck on what to do. Any thoughts?


enter image description here




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...