1\name{showWKT}
2\alias{showWKT}
3\alias{showEPSG}
4\alias{showP4}
5\alias{showSRID}
6\alias{get_P6_datum_hard_fail}
7\alias{set_P6_datum_hard_fail}
8\alias{get_thin_PROJ6_warnings}
9\alias{set_thin_PROJ6_warnings}
10\alias{get_prefer_proj}
11\alias{set_prefer_proj}
12\alias{get_rgdal_show_exportToProj4_warnings}
13\alias{set_rgdal_show_exportToProj4_warnings}
14\alias{get_PROJ6_warnings_count}
15\alias{OSRIsProjected}
16%- Also NEED an '\alias' for EACH other topic documented here.
17\title{Show Well-Known Text spatial reference system metadata}
18\description{
19In modern workflows with PROJ >= 6 and GDAL >= 3, use only \code{showSRID()}
20  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.
21}
22\usage{
23showWKT(p4s, file = NULL, morphToESRI = FALSE, enforce_xy = NULL)
24showP4(wkt, morphFromESRI=FALSE, enforce_xy = NULL)
25showEPSG(p4s, enforce_xy = NULL)
26showSRID(inSRID, format="WKT2", multiline="NO", enforce_xy = NULL, EPSG_to_init=TRUE,
27 prefer_proj=NULL)
28get_P6_datum_hard_fail()
29set_P6_datum_hard_fail(value)
30get_thin_PROJ6_warnings()
31set_thin_PROJ6_warnings(value)
32get_prefer_proj()
33set_prefer_proj(value)
34get_rgdal_show_exportToProj4_warnings()
35set_rgdal_show_exportToProj4_warnings(value)
36get_PROJ6_warnings_count()
37OSRIsProjected(obj)
38}
39%- maybe also 'usage' for other objects documented here.
40\arguments{
41  \item{p4s}{A valid PROJ.4 string representing a spatial reference system}
42  \item{file}{if not NULL, a file name to which the output Well-Known Text representation should be written}
43  \item{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: \url{https://github.com/edzer/sp/issues/75}}
44  \item{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.}
45  \item{wkt}{A valid WKT character string representing a spatial reference system}
46  \item{morphFromESRI}{default TRUE, morph the WKT string from the representation used by ESRI}
47  \item{inSRID}{Input coordinate reference string}
48  \item{obj}{valid CRS object}
49  \item{format}{Output format, default WKT2}
50  \item{multiline}{Multiline output, either \code{"NO"} or \code{"YES"}}
51  \item{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}
52  \item{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 \code{get_prefer_proj()} set on startup to TRUE.}
53%  \item{prefer_proj}{default FALSE, if TRUE, use the PROJ library directly rather than through GDAL}
54  \item{value}{a logical value. For \code{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 \code{try}. For \code{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 \code{get_PROJ6_warnings_count()}. For \code{set_rgdal_show_exportToProj4_warnings()}, default in \pkg{rgdal} version 1.5.* TRUE, from 1.6 FALSE. The \code{options("rgdal_show_exportToProj4_warnings"="x")} may be used before loading \pkg{rgdal} to set the internal logical variables; if the option is set to \code{"all"}, all warnings reporting CRS degradation stemming from the GDAL OSR function \code{exportToProj4()} even if trivial are reported; if set to \code{"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.
55}
56}
57
58\note{The \code{options("rgdal_show_exportToProj4_warnings"="x")} may be used before loading \pkg{rgdal} to set the internal logical variables; if the option is set to \code{"all"}, all warnings reporting CRS degradation stemming from the GDAL OSR function \code{exportToProj4()} even if trivial are reported; if set to \code{"thin"}, all warnings are detected but thinned so that one report is given per function call; if set to \code{"none"}, the degradations are detected but not reported.}
59
60\value{
61  For \code{showWKT}, a character string containing the WKT representation of the PROJ.4 string.
62}
63\references{\url{https://gdal.org/tutorials/osr_api_tut.html}}
64\author{Roger Bivand}
65
66\seealso{\code{\link[sp]{is.projected}}, \code{\link[sp]{CRS-class}}}
67\examples{
68set_thin_PROJ6_warnings(TRUE)
69cities <- readOGR(system.file("vectors", package = "rgdal")[1], "cities")
70readLines(system.file("vectors/cities.prj", package = "rgdal")[1])
71showWKT(proj4string(cities))
72showWKT("+init=epsg:28992")
73showP4(showWKT("+init=epsg:28992"))
74showEPSG("+proj=utm +zone=30")
75showEPSG("+proj=longlat +ellps=WGS84")
76exts <- rgdal_extSoftVersion()
77run <- new_proj_and_gdal()
78if (run) {
79  cat(showSRID("EPSG:27700", multiline="YES"), "\n")
80}
81if (run) {
82(prj <- showSRID("EPSG:27700", "PROJ"))
83}
84if (run) {
85showSRID(paste0(prj, " +datum=OSGB36"), "WKT1")
86}
87if (run) {
88showSRID(paste0(prj, " +towgs84=370.936,-108.938,435.682"), "WKT1")
89}
90if (run) {
91showSRID(paste0(prj, " +nadgrids=OSTN15_NTv2_OSGBtoETRS.gsb"), "WKT1")
92}
93if (run) {
94showSRID(paste0(prj, " +datum=OSGB36"), "WKT2")
95}
96if (run) {
97showSRID(paste0(prj, " +towgs84=370.936,-108.938,435.682"), "WKT2")
98}
99if (run) {
100showSRID(paste0(prj, " +nadgrids=OSTN15_NTv2_OSGBtoETRS.gsb"), "WKT2")
101}
102if (run) {
103showSRID("ESRI:102761", "WKT2")
104}
105if (run) {
106showSRID("OGC:CRS84", "WKT2")
107}
108if (run) {
109showSRID("urn:ogc:def:crs:OGC:1.3:CRS84", "WKT2")
110}
111if (run) {
112try(showSRID("", "WKT2"))
113}
114
115OSRIsProjected(CRS("+proj=longlat"))
116OSRIsProjected(CRS("+proj=geocent"))
117OSRIsProjected(CRS("+proj=geocent +units=km"))
118}
119\keyword{spatial}
120
121