Learn R Programming

lidR (version 2.1.4)

projection: Get or set the projection of a LAS* object

Description

Get or set the projection of a LAS* object with the function projection. Functions epsg and wkt are reserved for advanced users (see details).

Usage

epsg(object, ...)

epsg(object) <- value

wkt(object, ...)

wkt(object) <- value

# S4 method for LASheader projection(x, asText = TRUE)

# S4 method for LASheader epsg(object, ...)

# S4 method for LASheader epsg(object) <- value

# S4 method for LASheader wkt(object, ...)

# S4 method for LASheader wkt(object) <- value

# S4 method for LAS projection(x) <- value

# S4 method for LAS epsg(object)

# S4 method for LAS epsg(object) <- value

# S4 method for LAS wkt(object)

# S4 method for LAS wkt(object) <- value

Arguments

object, x

An object of class LAS or eventually LASheader (regular users don't need to manipulate LASheader objects).

...

Unused.

value

A CRS object or a proj4string string for functionprojection. An EPSG code as integer for function epsg. A WKT string for function wkt.

asText

logical. If TRUE, the projection is returned as text. Otherwise a CRS object is returned.

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.4)

  • Store a WTK string (for LAS 1.4)

On the other hand, all spatial R packages use a proj4string 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 proj4string in a format that can be understood by R packages.

  • projection<-: updates the CRS from a proj4string. It updates the header either with the EPSG code for LAS formats < 1.4 or with a WKT string for LAS format 1.4 and updates the proj4string slot. This function should always be preferred.

  • epsg<-: updates the CRS from an EPSG code. It adds the EPSG code in the header and updates the proj4string slot.

  • wkt<-: updates the CRS from a WKT string. It adds the WKT string in the header and updates the proj4string slot.

  • projection: reads the proj4string from the proj4string slot.

  • epsg: reads the epsg code from the header.

  • wkt: reads the WKT string from the header.

Examples

Run this code
# NOT RUN {
LASfile <- system.file("extdata", "Megaplot.laz", package="lidR")
las <- readLAS(LASfile)
crs <- sp::CRS("+init=epsg:26918")

projection(las)
projection(las) <- crs
# }

Run the code above in your browser using DataLab