[R-sig-Geo] Large PDF files when using tiff raster images as background
Roger Bivand
Roger.Bivand at nhh.no
Tue May 5 09:36:00 CEST 2009
On Mon, 4 May 2009, dominik baenninger wrote:
> Dear list,
>
> When plotting spatial informaion it is common to use a pixel map as
> background. Therefore I used the following commands (in brief)
>
> library(sp)
> library(rgdal)
>
> pdf()
> readGDAL(geotiff-file)
> image()
> plot(...,add=T)
> dev.off()
>
> This works fine, however, the original tiff file has a size of about 600kb,
> the pdf 20MB even I do not add any further information.
You have (at least) two choices - making the choice depends on which
output graphics device you want to use. All R graphics draw raster cells
as filled rectangles, so that on a PDF you will get many filled
rectangles, hence the size of the output file. To reduce the size,
decimate the raster with the output.dim= argument in readGDAL - you lose
resolution, but reduce the number of filled rectangles.
An alternative is to use a bitmapped device such as png(), possibly trying
to set the width and height to suit the raster object - see GE_SpatialGrid
in maptools for examples of the manipulations needed for making Google
Earth PNG image overlays. A compressed bitmapped device will yield an
image not dissimilar to the input raster in size.
Hope this helps,
Roger
> Since I like to add point and line information with the plot command I
> would like to generate some kind of vecotrbased graphics. Any idea how I
> can the geotiff-background without producing large files?
>
> Thanks for any hint in advance.
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no
More information about the R-sig-Geo
mailing list