Description Usage Arguments Details Value

View source: R/set_projection.R

The function `set_projection`

sets the projection of a shape file. It is
a convenient wrapper of `st_transform`

(or `st_transform_proj`

, see details) and
`projectRaster`

with shortcuts for commonly
used projections. The projection can also be set directly in the plot call
with `tm_shape`

. This function is also used to set the current
projection information if this is missing. The function `get_projection`

is used to get the projection information.

1 2 3 4 5 | ```
set_projection(shp, projection = NA, current.projection = NA,
overwrite.current.projection = FALSE)
get_projection(shp, guess.longlat = FALSE, output = c("character", "crs",
"epsg", "CRS"))
``` |

`shp` |
shape object, which is an object from a class defined by the |

`projection` |
new projection. See |

`current.projection` |
the current projection of |

`overwrite.current.projection` |
logical that determines whether the current projection is overwritten if it already has a projection that is different. |

`guess.longlat` |
if |

`output` |
output format of the projection. One of |

For `sf`

objects, `set_projection`

first tries to use `sf::st_transform`

, which uses the GDAL API. For some projections, most notably Winkel Tripel (`"wintri"`

), is doesn't work. In these cases, `set_projection`

will use `lwgeom::st_transform_proj`

, which uses the PROJ.4 API.

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_projection`

returns a (transformed) shape object with updated projection information. `get_projection`

returns the `PROJ.4`

character string of `shp`

.

tmaptools documentation built on Aug. 9, 2018, 9:04 a.m.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.