sp_transform: Convenience function to transform a spatial object's...

View source: R/sp_transform.R

sp_transformR Documentation

Convenience function to transform a spatial object's projection system to WGS84 latitude and longitude.

Description

sp_transform is a simple wrapper for spTransform which has been written so spatial objects can be transformed quickly without the need to remember the WGS84 proj4 string. sp_transform will force projections when the spatial object contains no projection information.

Usage

sp_transform(sp, to = NA, warn = TRUE)

Arguments

sp

Spatial object which is to be transformed.

to

A proj4 string for the projection-transformation. Default is the WGS84 string.

warn

Should the functions raise a warning when the projection is forced?

Details

sp_transform will also work for raster layers.

Author(s)

Stuart K. Grange

See Also

spTransform, sp_projection, projection_wgs84

Examples

## Not run: 

# Load a shape file of canal locks for the UK
sp_locks <- sp_read("uk-canals", "locks")

# Print projection string
sp_projection(sp_locks)

# Convert the shape file's projection (UK's Ordnance Survey National Grid)
to WGS84 latitude and longitude
sp_locks <- sp_transform(sp_locks)

# Print projection string
sp_projection(sp_locks)


## End(Not run)


skgrange/gissr documentation built on Feb. 24, 2024, 2:55 p.m.