Learn R Programming

rgdal (version 1.6-7)

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

showP4(wkt, morphFromESRI=FALSE, 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)

Value

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

Arguments

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.

Author

Roger Bivand

References

https://gdal.org/tutorials/osr_api_tut.html

See Also

Examples

Run this code
set_thin_PROJ6_warnings(TRUE)
cities <- readOGR(system.file("vectors", package = "rgdal")[1], "cities")
readLines(system.file("vectors/cities.prj", package = "rgdal")[1])
showP4(showWKT("+init=epsg:28992"))
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"))

Run the code above in your browser using DataLab