Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

showWKT

Show Well-Known Text spatial reference system metadata


Description

In modern workflows with PROJ >= 6 and GDAL >= 3, use only showSRID() DEPRECATED: Use GDAL/OGR spatial reference objects to convert a PROJ.4 representation to a Well-Known Text representation, and report an EPSG code if it can be determined by OGR SRS services.

Usage

showWKT(p4s, file = NULL, morphToESRI = FALSE, enforce_xy = NULL)
showP4(wkt, morphFromESRI=FALSE, enforce_xy = NULL)
showEPSG(p4s, enforce_xy = NULL)
showSRID(inSRID, format="WKT2", multiline="NO", enforce_xy = NULL, EPSG_to_init=TRUE,
 prefer_proj=NULL)
get_P6_datum_hard_fail()
set_P6_datum_hard_fail(value)
get_thin_PROJ6_warnings()
set_thin_PROJ6_warnings(value)
get_prefer_proj()
set_prefer_proj(value)
get_rgdal_show_exportToProj4_warnings()
set_rgdal_show_exportToProj4_warnings(value)
get_PROJ6_warnings_count()
OSRIsProjected(obj)

Arguments

p4s

A valid PROJ.4 string representing a spatial reference system

file

if not NULL, a file name to which the output Well-Known Text representation should be written

morphToESRI

default FALSE, morph the WKT string to the representation used by ESRI; set FALSE by default 2020-03-04 to avoid occasional Windows crashes seen when passing a very modern WKT string to an old version of PROJ: https://github.com/edzer/sp/issues/75

enforce_xy

(PROJ6+/GDAL3+) either use global setting (default NULL) or override policy for coordinate ordering easting/x as first axis, northing/y as second axis.

wkt

A valid WKT character string representing a spatial reference system

morphFromESRI

default TRUE, morph the WKT string from the representation used by ESRI

inSRID

Input coordinate reference string

obj

valid CRS object

format

Output format, default WKT2

multiline

Multiline output, either "NO" or "YES"

EPSG_to_init

default TRUE, workaround for PROJ 6.3.0 frailty leading to the dropping of +ellps= and +units=; DATUM seems to disappear in the internal definition

prefer_proj

default NULL, if TRUE, use PROJ compiled code directly, rather than FALSE using PROJ via GDAL SRS; if NULL, uses value shown by get_prefer_proj() set on startup to TRUE.

value

a logical value. For set_P6_datum_hard_fail(): by default, a deprecated/ignored input DATUM key/value pair on reading a file with PROJ6 will give a warning (default FALSE); if TRUE, an error is triggered, which may be trapped using try. For set_thin_PROJ6_warnings() default FALSE, can be set to TRUE to report only once and count the number of non-issues warnings, retrieved by get_PROJ6_warnings_count(). For set_rgdal_show_exportToProj4_warnings(), default in rgdal version 1.5.* TRUE, from 1.6 FALSE. The options("rgdal_show_exportToProj4_warnings"="x") may be used before loading rgdal to set the internal logical variables; if the option is set to "all", all warnings reporting CRS degradation stemming from the GDAL OSR function exportToProj4() even if trivial are reported; if set to "thin", all warnings are detected but thinned so that one report is given per function call; if set to "none", the degradations are detected but not reported.

Value

For showWKT, a character string containing the WKT representation of the PROJ.4 string.

Note

The options("rgdal_show_exportToProj4_warnings"="x") may be used before loading rgdal to set the internal logical variables; if the option is set to "all", all warnings reporting CRS degradation stemming from the GDAL OSR function exportToProj4() even if trivial are reported; if set to "thin", all warnings are detected but thinned so that one report is given per function call; if set to "none", the degradations are detected but not reported.

Author(s)

Roger Bivand

References

See Also

Examples

set_thin_PROJ6_warnings(TRUE)
cities <- readOGR(system.file("vectors", package = "rgdal")[1], "cities")
readLines(system.file("vectors/cities.prj", package = "rgdal")[1])
showWKT(proj4string(cities))
showWKT("+init=epsg:28992")
showP4(showWKT("+init=epsg:28992"))
showEPSG("+proj=utm +zone=30")
showEPSG("+proj=longlat +ellps=WGS84")
exts <- rgdal_extSoftVersion()
run <- new_proj_and_gdal()
if (run) {
  cat(showSRID("EPSG:27700", multiline="YES"), "\n")
}
if (run) {
(prj <- showSRID("EPSG:27700", "PROJ"))
}
if (run) {
showSRID(paste0(prj, " +datum=OSGB36"), "WKT1")
}
if (run) {
showSRID(paste0(prj, " +towgs84=370.936,-108.938,435.682"), "WKT1")
}
if (run) {
showSRID(paste0(prj, " +nadgrids=OSTN15_NTv2_OSGBtoETRS.gsb"), "WKT1")
}
if (run) {
showSRID(paste0(prj, " +datum=OSGB36"), "WKT2")
}
if (run) {
showSRID(paste0(prj, " +towgs84=370.936,-108.938,435.682"), "WKT2")
}
if (run) {
showSRID(paste0(prj, " +nadgrids=OSTN15_NTv2_OSGBtoETRS.gsb"), "WKT2")
}
if (run) {
showSRID("ESRI:102761", "WKT2")
}
if (run) {
showSRID("OGC:CRS84", "WKT2")
}
if (run) {
showSRID("urn:ogc:def:crs:OGC:1.3:CRS84", "WKT2")
}
if (run) {
try(showSRID("", "WKT2"))
}

OSRIsProjected(CRS("+proj=longlat"))
OSRIsProjected(CRS("+proj=geocent"))
OSRIsProjected(CRS("+proj=geocent +units=km"))

rgdal

Bindings for the 'Geospatial' Data Abstraction Library

v1.5-23
GPL (>= 2)
Authors
Roger Bivand [cre, aut] (<https://orcid.org/0000-0003-2392-6140>), Tim Keitt [aut], Barry Rowlingson [aut, ctb], Edzer Pebesma [ctb], Michael Sumner [ctb], Robert Hijmans [ctb], Daniel Baston [ctb], Even Rouault [cph, ctb], Frank Warmerdam [cph, ctb], Jeroen Ooms [ctb], Colin Rundel [ctb]
Initial release
2021-02-03

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.