1

I have a levelplot in made in R. I want it to save it as an SVG or Metafile. Since the levelplot has multiple layers and multiple rasters, the final svg or metafile (EMF) is huge (~ 300mb). Is there any way to save it as a small file without losing the details?

I have tried svglite and it is bringing the size into 150mb. I need a much lighter file.

tms
  • 11
  • 2
  • 1
    Likely the reason that it is large is because there are lots of graphical elements being displayed. The intent of svg/emf is to support all of them, so if you have 10 elements versus 10M elements, it _must_ store all elements, so the file size is always going to scale with the size of the data. If you truly need a smaller file, then you can either (1) use `png(..)` or another raster format; or (2) sample your the data plotted. – r2evans Jul 07 '23 at 15:06
  • Thank you @r2evans for the reply and explanation. Is there any way I can export the plot in high quality? It's for my journal publication and I am using Microsoft word for preparing the manuscript. I experimented with native png and tiff commands in r with different resolutions. I couldn't get a desired output. – tms Jul 08 '23 at 10:38
  • 1
    If there is tons of rasters and layers, then I would suggest to consider, if there is no way to aggregate the data in some way, like points in (predefined) polygons, or similar way. And then plot it as `.png`, usually 240 dpi is enough for any publisher. My usuall approach which merges few terra:plots(rasters) + couple of vector layers: `grDevices::png(file=paste0({{filename}}, ".png"), width=1600, height=1600, res=240) .... plot()... grDevices::dev.off()` – Grzegorz Sapijaszko Jul 08 '23 at 19:23
  • I will try with png(). Thanks @GrzegorzSapijaszko for the suggestions. – tms Jul 09 '23 at 13:59

0 Answers0