Set and get the map projection
set_projection sets the projection of a shape file. It is
a convenient wrapper of
projectRaster with shortcuts for commonly
used projections. The projection can also be set directly in the plot call
tm_shape. This function is also used to set the current
projection information if this is missing. The function
is used to get the projection information.
set_projection(shp, projection = NA, current.projection = NA, overwrite.current.projection = FALSE)get_projection(shp, as.CRS = FALSE, guess.longlat = FALSE)
- shape object of class
- new projection. See
get_proj4for options. This argument is only used to transform the
current.projectionto specify the current projection of
- the current projection of
get_proj4for possible options. Only use this if the current projection is missing or wrong.
- logical that determines whether the current projection is overwritten if it already has a projection that is different.
- should a CRS object be returned instead of a PROJ.4 character string? Default is
TRUE, it checks if the coordinates are within -180/180 and -90/90, and if so, it returns the WGS84 longlat projection (which is
For raster objects, the projection method is based on the type of data. For numeric layers, the bilinear method is used, and for categorical layers the nearest neighbor. See
projectRaster for details.
set_projectionreturns a (transformed) shape object with updated projection information.
PROJ.4character string of