Reputation: 551
I am trying to convert some ASCII
test files into .tif
files, so i can use the .tif
files in bnspatial
.
Any suggestions? Is there a package out there that does this or do i need to link R with a GIS software?
Upvotes: 1
Views: 1323
Reputation: 47051
You can do something along these lines:
library(terra)
fasc <- list.files(pattern='\\.asc$', full=TRUE)
ftif <- gsub("\\.asc$", ".tif", fasc)
for (i in 1:length(fasc)) {
r <- rast(fasc[i])
r <- writeRaster(r, ftif[i])
}
Upvotes: 3