1

I'm trying to get rid of some white space produced by levelplot in the rasterVis package. I'm using the dismo package to get a Google map, then using levelplot to plot it. However, there is a thin strip of white around the map. How do I remove that white space?

library(dismo)
library(rasterVis)

g_map = gmap(extent(c(-79,-58,36,50)),type="satellite",zoom=7,lonlat=TRUE,scale=1)


g_map_lv = levelplot(g_map,maxpixel=ncell(g_map),col.regions=g_map@legend@colortable,at=0:255,panel=panel.levelplot.raster,interpolate=TRUE,colorkey=FALSE,margin=FALSE,scales="sliced")

enter image description here

www
  • 38,575
  • 12
  • 48
  • 84
user13317
  • 451
  • 3
  • 13

1 Answers1

3

The outer rows and columns of the g_map object are NA. For example:

g_map[1,1]

You can remove them with trim before plotting:

g_map <- trim(g_map)
Oscar Perpiñán
  • 4,491
  • 17
  • 28