This is a convenience temporary function which returns the WKT representation of a CRS, using sf::st_as_text() in case PROJ < 3, rgdal::CRS() otherwise. This has the advantage to perform precise transformations with PROJ >=3, and to avoid conversion errors (see here). This function will be deleted whenever sf will manage WKT2.

st_as_text_2(x, pretty = FALSE)

Arguments

x

object of class sfg, sfc or crs

pretty

logical; if TRUE, print human-readable well-known-text representation of a coordinate reference system

Value

Well-known Text representation of simple feature geometry or coordinate reference system

Author

Luigi Ranghetti, phD (2019) luigi@ranghetti.info

Examples

sen2r:::st_as_text_2(sf::st_crs(32632))
#> [1] "PROJCRS[\"WGS 84 / UTM zone 32N\",\n BASEGEOGCRS[\"WGS 84\",\n DATUM[\"World Geodetic System 1984\",\n ELLIPSOID[\"WGS 84\",6378137,298.257223563,\n LENGTHUNIT[\"metre\",1]]],\n PRIMEM[\"Greenwich\",0,\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n ID[\"EPSG\",4326]],\n CONVERSION[\"UTM zone 32N\",\n METHOD[\"Transverse Mercator\",\n ID[\"EPSG\",9807]],\n PARAMETER[\"Latitude of natural origin\",0,\n ANGLEUNIT[\"degree\",0.0174532925199433],\n ID[\"EPSG\",8801]],\n PARAMETER[\"Longitude of natural origin\",9,\n ANGLEUNIT[\"degree\",0.0174532925199433],\n ID[\"EPSG\",8802]],\n PARAMETER[\"Scale factor at natural origin\",0.9996,\n SCALEUNIT[\"unity\",1],\n ID[\"EPSG\",8805]],\n PARAMETER[\"False easting\",500000,\n LENGTHUNIT[\"metre\",1],\n ID[\"EPSG\",8806]],\n PARAMETER[\"False northing\",0,\n LENGTHUNIT[\"metre\",1],\n ID[\"EPSG\",8807]]],\n CS[Cartesian,2],\n AXIS[\"(E)\",east,\n ORDER[1],\n LENGTHUNIT[\"metre\",1]],\n AXIS[\"(N)\",north,\n ORDER[2],\n LENGTHUNIT[\"metre\",1]],\n USAGE[\n SCOPE[\"unknown\"],\n AREA[\"World - N hemisphere - 6°E to 12°E - by country\"],\n BBOX[0,6,84,12]],\n ID[\"EPSG\",32632]]"