looking at the help file creating a raster in terra is pretty similar to raster, however, I keep getting an 'empty srs' error (for other operations in terra also).
What is srs? It seems to be the same as crs? why the name change?
library(raster)
d <- raster(xmn=1, xmx=17, ymn=46, ymx=57, nrows=1320, ncols = 960, vals = 1, crs = 4326)
library(terra)
d <- rast(xmin=1, xmax=17, ymin=46, ymax=57, nrows=1320, ncols = 960, vals = 1, crs = 4326)
This makes no sense:
Because the number
4326is not a spatial/coordinate reference system. I agree that the error message is not especially helpful.Presumably, you want to use that EPSG code. In that case you can do
You probably thought you could use
crs = 4326because the equivalent is valid with the "sf" package. The reasons to require the ESPG prefix are that (1) it is not the only coding system (e.g. ESRI:) and (2) it much improves the readability of the code: a single number to an entry in an unspecified database is a very opaque reference.You can also use the more descriptive PROJ notation: