st_crs function

Get or set the projection of a LAS* object

Get or set the projection of a LAS* object

Get or set the projection of a LAS* object. st_crs() extends sf:st_crs(), projection() and crs() extend raster:projection() and raster:crs(). projection() and crs() are provided for backward compatibility. For epsg() and wkt(), see details.

## S3 method for class 'LAS' st_crs(x, ...) ## S3 method for class 'LAScatalog' st_crs(x, ...) ## S3 method for class 'LASheader' st_crs(x, ...) ## S3 method for class 'LAScluster' st_crs(x, ...) ## S3 replacement method for class 'LAS' st_crs(x) <- value ## S3 replacement method for class 'LASheader' st_crs(x) <- value ## S3 replacement method for class 'LAScatalog' st_crs(x) <- value projection(x, asText = TRUE) projection(x) <- value crs(x, asText = FALSE) crs(x, ...) <- value ## S4 method for signature 'LASheader' crs(x, asText = FALSE) ## S4 method for signature 'LAS' crs(x, asText = FALSE) ## S4 replacement method for signature 'LAS' crs(x, ...) <- value ## S4 method for signature 'LAScatalog' crs(x, asText = FALSE) ## S4 method for signature 'LAScluster' crs(x, asText = FALSE) ## S4 replacement method for signature 'LAScatalog' crs(x, ...) <- value ## S4 replacement method for signature 'LASheader' crs(x, ...) <- value epsg(object, ...) epsg(object) <- value ## S4 method for signature 'LASheader' epsg(object, ...) ## S4 replacement method for signature 'LASheader' epsg(object) <- value ## S4 method for signature 'LAS' epsg(object) ## S4 replacement method for signature 'LAS' epsg(object) <- value wkt(obj) wkt(obj) <- value ## S4 method for signature 'LASheader' wkt(obj) ## S4 replacement method for signature 'LASheader' wkt(obj) <- value ## S4 method for signature 'LAS' wkt(obj) ## S4 replacement method for signature 'LAS' wkt(obj) <- value

Arguments

  • x, object, obj: An object of class LAS*
  • ...: Unused.
  • value: A CRS or a crs or a proj4string string or WKT string or an EPSG code.
  • asText: logical. If TRUE, the projection is returned as text. Otherwise a CRS object is returned.

Returns

A st_crs() returns a sf::crs. projection() and crs() return a sp::CRS and should no longer be used.

Details

There are two ways to store the CRS of a point cloud in a LAS file:

  • Store an EPSG code (for LAS 1.0 to 1.3)
  • Store a WTK string (for LAS 1.4)

On the other hand, R spatial packages use a crs object to store the CRS. This is why the CRS is duplicated in a LAS object. The information belongs within the header in a format that can be written in a LAS file and in the slot crs, and also in a format that can be understood by other R packages.

  • st_crs return the CRS in sf format.
  • st_crs\<-: assigns a CRS from a CRS (sp), a crs (sf), a WKT string, a proj4string or an epsg code. It updates the header of the LAS object either with the EPSG code for LAS formats < 1.4 or with a WKT string
  • epsg: reads the epsg code from the header.
  • wkt: reads the WKT string from the header.

Examples

LASfile <- system.file("extdata", "Megaplot.laz", package="lidR") las <- readLAS(LASfile) # Get the EPSG code stored in the header (returns 0 if not recorded) epsg(las) # Get the WKT string stored in the header (LAS >= 1.4) wkt(las) # Overwrite the CRS (but does not reproject) st_crs(las) <- 26918 las
  • Maintainer: Jean-Romain Roussel
  • License: GPL-3
  • Last published: 2024-07-09