# \donttest{
## Prepare file paths
td <- tempdir()
lux <- system.file("ex/lux.shp", package = "terra")
lux_merc <- file.path(td, "mercator.shp")
lux_lcc <- file.path(td, "lcc.shp")
## Reproject to 'WGS 84/World Mercator'
## https://en.wikipedia.org/wiki/Mercator_projection
ogr2ogr(lux, lux_merc, t_srs = "EPSG:3395", overwrite = TRUE)
## Reproject to a Canadian 'Lambert conformal conic projection'
## https://en.wikipedia.org/wiki/Lambert_conformal_conic_projection
ogr2ogr(lux, lux_lcc, t_srs = "EPSG:3347", overwrite = TRUE)
if(require(terra)) {
op <- par(mfcol = c(1,2))
plot(vect(lux_merc), main = "WGS 84",
border = "darkgrey", col = gray.colors(12))
plot(vect(lux_lcc), main = "LCC",
border = "darkgrey", col = gray.colors(12))
par(op)
}
# }
Run the code above in your browser using DataLab