check_projection {plotKML}R Documentation

Extracts the proj4 parameters and checks if the projection matches the referent CRS

Description

Function parse_proj4 gets the proj4 string from a space-time object and check_projection checks if the input projection is compatible with the referent projection system. The referent system is by default the longlat projection with WGS84 datum (KML-compatible coordinates).

Usage

check_projection(obj, control = TRUE, 
                 ref_CRS = get("ref_CRS", envir = plotKML.opts))

Arguments

obj

object of class Spatial* or Raster*

control

logical; if TRUE, a logical value is returned, if FALSE, an error is thrown if the test failed

ref_CRS

the referent coordinate system.

Details

A cartographic projection is KML compatible if: (a) geographical coordinates are used, and (b) if they relate to the WGS84 ellispoid ("+proj=longlat +datum=WGS84"). You can also set your own local referent projection system by specifiying plotKML.env(ref_CRS = ...).

Warning

obj needs to have a proper proj4 string (CRS), otherwise check_projection will not run. If the geodetic datum is defined via the +towgs, consider converting the coordinates manually i.e. by using the spTransform or reproject method.

Author(s)

Pierre Roudier, Tomislav Hengl, and Dylan Beaudette

References

See Also

reproject, rgdal::CRS-class

Examples

data(eberg)
library(sp)
library(rgdal)
coordinates(eberg) <- ~X+Y
proj4string(eberg) <- CRS("+init=epsg:31467")
check_projection(eberg)
# not yet ready for export to KML;
parse_proj4(proj4string(eberg))
eberg.geo <- reproject(eberg)
check_projection(eberg.geo)
# ... now ready for export

[Package plotKML version 0.5-9 Index]