st_crs2 | R Documentation |
This function is a wrapper for sf::st_crs, unless
threating numeric character
strings as integers, and
accepting also UTM timezones, paths of spatial files and paths of
text files containing WKT like .prj (see details) .
st_crs2(x, ...)
x |
numeric, character, or object of class sf or sfc, being:
|
... |
other parameters passed to sf::st_crs. |
See sf::st_crs for details.
An object of class crs of length 2.
License: GPL 3.0
Luigi Ranghetti, phD (2019)
L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020). "sen2r": An R toolbox for automatically downloading and preprocessing Sentinel-2 satellite data. Computers & Geosciences, 139, 104473. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1016/j.cageo.2020.104473")}, URL: https://sen2r.ranghetti.info/.
## CRS from EPSG
st_crs2(32609)
st_crs2("EPSG:32609")
## CRS from UTM zone
st_crs2(9)
st_crs2("09")
st_crs2("9N")
st_crs2("09S")
## CRS from WKT (string or path)
(wkt_32n <- sf::st_as_text(sf::st_crs(32609)))
st_crs2(wkt_32n)
writeLines(wkt_32n, wkt_32n_path <- tempfile())
st_crs2(wkt_32n_path)
## Not run:
## CRS from spatial file path
raster_path <- system.file(
"extdata/out/S2A2A_20190723_022_Barbellino_BOA_10.tif",
package="sen2r"
)
vector_path <- system.file(
"extdata/vector/barbellino.geojson",
package="sen2r"
)
try( st_crs2(raster_path) )
st_crs2(vector_path)
## CRS from spatial files
st_crs2(stars::read_stars(raster_path))
st_crs2(sf::read_sf(vector_path))
## CRS from PROJ.4 string
# (avoid using this with PROJ >= 6!)
st_crs2("+init=epsg:32609") # this makes use of the EPSG code
st_crs2("+proj=utm +zone=9 +datum=WGS84 +units=m +no_defs")
st_crs2(raster::raster(raster_path)) # st_crs(raster) uses the PROJ.4 as input
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.