kml_screen: Add a screen overlay

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

View source: R/kml_screen.R

Description

Adds an image file (map legend or logo) as screen overlay. The same file connection is further accessible by other kml_*() functions such as kml_layer() and kml_close(). This allows creation of customized multi-layered KML files.

Usage

1
2
3
4
kml_screen(image.file, sname = "", 
     position = c("UL","ML","LL","BC","LR","MR","UR","TC")[1],
     overlayXY, screenXY, xyunits = c("fraction", "pixels", "insetPixels")[1], 
     rotation = 0, size = c(0,0) )

Arguments

image.file

image file to be used for screen overlay

sname

screen overlay name

position

one of the nine standard positions

overlayXY

manually specified tie point on the overlay image e.g. 'x="0" y="1"'

screenXY

manually specified matching tie point on the scren e.g. 'x="0" y="1"'

xyunits

values of the XY units (("pixels", "fraction", or "insetPixels")

rotation

(optional) rotation in degrees clock-wise

size

size correction in x and y direction

Details

If nothing else is specified the function looks for some of the nine typical positions: "UL" (upper left), "ML" (middle left), "LL" (lower left), "BC" (bottom centre), "LR" (lower right), "MR" (middle right), "UR" (upper right), and "TC" (top centre). The x and y values can be specified in three different ways: as pixels ("pixels"), as fractions of the image ("fraction"), or as inset pixels ("insetPixels") — an offset in pixels from the upper right corner of the image.

Note

The function, by default, calculates with fractions. If you change the xyunits type, all other elements need to be expressed in the same units.

Author(s)

Tomislav Hengl

References

See Also

kml-methods

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
library(rgdal)
library(sp)
data(eberg_zones)
## Not run: # add logo in the top-center:
kml_open("eberg_screen.kml")
kml_layer(eberg_zones)
logo = "http://meta.isric.org/images/ISRIC_right.png"
kml_screen(image.file = logo, position = "TC", sname = "ISRIC logo")
kml_close("eberg_screen.kml")
kml_compress("eberg_screen.kml")

## End(Not run)

Example output

plotKML version 0.6-1 (2020-03-08)
URL: http://plotkml.r-forge.r-project.org/
Loading required package: sp
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.
KML file opened for writing...
Reprojecting to +proj=longlat +datum=WGS84 +no_defs ...
Writing to KML...
Warning messages:
1: In wkt(obj) : CRS object has no comment
2: In spTransform(xSP, CRSobj, ...) :
  NULL source CRS comment, falling back to PROJ string
3: In spTransform(xSP, CRSobj, ...) : +init dropped in PROJ string
4: In wkt(obj) : CRS object has no comment
5: In wkt(obj) : CRS object has no comment
6: In showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj = prefer_proj) :
  Discarded datum Deutsches_Hauptdreiecksnetz in CRS definition,
 but +towgs84= values preserved
Closing  eberg_screen.kml
sh: 1: /usr/bin/zip: Permission denied

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