[R-sig-Geo] Saving plot as PDF from functions levelplot and gplot from rasterVis package
Oscar Perpiñán Lamigueiro
oscar.perpinan at upm.es
Wed Mar 21 11:29:18 CET 2012
Manuel Spínola <mspinola10 at gmail.com> writes:
> Dear list members,
>
> How can I save a map on pdf plotted with the functions levelplot or gplot
> from the rasterVis package without loosing quality of the map.
>
>> class(maparaster)
> [1] "RasterLayer"
> attr(,"package")
> [1] "raster"
>
>
> pdf("mp.pdf")
> levelplot(maparaster)
> dev.off()
Hello,
You should use trellis.device with lattice objects:
f <- system.file("external/test.grd", package="raster")
r <- raster(f)
##default
trellis.device(pdf, file='mp.pdf')
levelplot(r)
dev.off()
##smaller file
trellis.device(pdf, file='mpRaster.pdf')
levelplot(r, panel=panel.levelplot.raster)
dev.off()
##smaller file and interpolate
trellis.device(pdf, file='mpInterpolate.pdf')
levelplot(r, panel=panel.levelplot.raster, interpolate=TRUE)
dev.off()
Best,
Oscar.
--
Oscar Perpiñán Lamigueiro
Dpto. Ingeniería Eléctrica
EUITI-UPM
http://procomun.wordpress.com
More information about the R-sig-Geo
mailing list