Message Boards Message Boards

Adding GeoBackground to GeoGraphics increases file size excessively

Adding a GeoBackground to a GeoGraphics increases the file size enormously. Does anybody have any ideas for minimising the resulting size?

Adding a ReliefMap background to a simple plot increase the file size from 4kB to 4.3MB. Adding a selection of plots (5) means the resulting file is too large to send by email.

POSTED BY: Nigel King
7 Replies

I suspect the original issue may be related to the fact that certain kinds of graphics, notably GeoGraphics, get converted to rasterized form on conversion to PDF. It seems to be especially true for GeoGraphics with background imagery, and even happens to any overlaid 'vector' graphics. My hypothesis is that the need to maintain the illusion of sharp vector graphics means that the rasterization happens at very high resolution, much higher than (and essentially independently of) any background image.

Why a hybrid PDF with both raster and vector components can't be created in certain cases is unclear.

POSTED BY: Gareth Russell

Jack, thanks for you contribution but I am referring to the saving or printing of the complete notebook as pdf.

I have finally solved the issue by saving the file as pdf with the extension tmp and then converting the tmp to pdf using Ghostscript. I enclose the function compressPDF which works amazingly reducing the file size from a typical 60MB to 2MB.

compressPDF[filein_,fileout_]:=Module[{},
RunProcess[{"/usr/local/bin/gs","-sDEVICE=pdfwrite","-dCompatibilityLevel=1.4","-dPDFSETTINGS=/ebook",
         "-dNOPAUSE","-dQUIET","-dBATCH","-sOutputFile="<>fileout,filein}]]
POSTED BY: Nigel King

I have used GeoResolution which reduces the zoom level but theByteCount has not changed and is approximately equal to the number of pixels x 4 where the number of pixels seems sufficient to populate the screen fully. ImageResize just makes the image smaller.

What appears to be missing is some sort of compression such as JPG for the background which could easily reduce the file and memory size by a factor of about 8. The lines drawn on the background are vector graphics which are relatively small.

Converting the notebook to pdf does not improve the file size, in fact, the notebook with many pictures increases to about double the size on using NotebookPrint[nb,pfilename].

POSTED BY: Nigel King

Not sure what you mean. The output of Geographics is vector graphics but once you save it as an image it is saved using compression of your choice say

Export{NotebookDirectory[]<> “filename.jpg”, somegeographics]

That compresses it using jpg.

As for pdf I use PDF software such as PDFExpert to reduce graphics bloat.

POSTED BY: Jack I Houng

You can alway reduce the file size of the output image using ImageResize[]

POSTED BY: Jack I Houng

Raising this question immediately alerted me to the possibility that you highlight. It will be necessary for me to have an automated method of choosing and automated way of choosing GeoZoomLevel dependent upon the range of data to be plotted. GeoResolution however is new to me. Thanks.

POSTED BY: Nigel King

Did you try different values for GeoZoomLevel (or GeoResolution) as options for GeoGraphics? And of course ImageSize does matter, too.

POSTED BY: Henrik Schachner
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract