kml_compress: Compress a KML file with auxiliary files

Description Usage Arguments Details Author(s) References See Also Examples

View source: R/kml_compress.R

Description

Compresses the KML file toghether with the auxiliary files (images, models, textures) using the default ZIP program.

Usage

1
kml_compress(file.name, zip = "", files = "", rm = FALSE, ...)

Arguments

file.name

KML file name

zip

(optional) location of an external ZIP program

files

a character vector specifying the list of auxiliary files

rm

logical; specify whether to remove temporary files

...

other kml arguments

Details

The KMZ file can carry the model files (.dae), textures and ground overlay images. For practical purposes, we recommend that you, instead of compressing the images together with the KML file, consider serving the ground overlay images via a server i.e. as network links.
If no internal ZIP program exists, the function looks for the system ZIP program:

Sys.getenv("R_ZIPCMD", "zip")

External ZIP program can also be specified via the zip argument.

Author(s)

Pierre Roudier, Tomislav Hengl and Dylan Beaudette

References

See Also

kml-methods, kml_open

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
data(eberg)
eberg <- eberg[runif(nrow(eberg))<.1,] 
library(sp)
library(rgdal)
library(raster)
coordinates(eberg) <- ~X+Y
proj4string(eberg) <- CRS("+init=epsg:31467")
kml.file = paste0(tempdir(), "/eberg.kml")
kml_open(kml.file)
kml_layer(eberg, colour = CLYMHT_A)
kml_close(kml.file)
# compress:
kml_compress(kml.file)

Example output

plotKML version 0.6-1 (2020-03-08)
URL: http://plotkml.r-forge.r-project.org/
rgdal: version: 1.5-18, (SVN revision 1082)
Geospatial Data Abstraction Library extensions to R successfully loaded
Loaded GDAL runtime: GDAL 3.0.4, released 2020/01/28
Path to GDAL shared files: /usr/share/gdal
GDAL binary built with GEOS: TRUE 
Loaded PROJ runtime: Rel. 6.3.1, February 10th, 2020, [PJ_VERSION: 631]
Path to PROJ shared files: /usr/share/proj
Linking to sp version:1.4-4
To mute warnings of possible GDAL/OSR exportToProj4() degradation,
use options("rgdal_show_exportToProj4_warnings"="none") before loading rgdal.
Warning message:
In showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj = prefer_proj) :
  Discarded datum Deutsches_Hauptdreiecksnetz in CRS definition
KML file opened for writing...
Reprojecting to +proj=longlat +datum=WGS84 +no_defs ...
Writing to KML...
Warning message:
In proj4string(obj) : CRS object has comment, which is lost in output
Closing  /work/tmp/tmp/RtmpwZko31/eberg.kml
sh: 1: /usr/bin/zip: Permission denied

plotKML documentation built on April 27, 2021, 3:01 p.m.