gplot_data.Rd
Transform raster as data.frame to be later used with ggplot Modified from rasterVis::gplot
gplot_data(x, maxpixels = 50000)
x | A Raster* object |
---|---|
maxpixels | Maximum number of pixels to use |
rasterVis::gplot is nice to plot a raster in a ggplot but if you want to plot different rasters on the same plot, you are stuck. If you want to add other information or transform your raster as a category raster, you can not do it. With `cartomisc::gplot_data`, you retrieve your raster as a data.frame that can be modified as wanted using `dplyr` and then plot in `ggplot` using `geom_tile`. If Raster has levels, they will be joined to the final tibble.