rspatial/raster

v3.6.0 Problems saving and reading (only via gdal?)

waternumbers opened this issue · 2 comments

I've been looking at reverse dependency errors for v3.6.0 flagged here

Installing raster from R-universe or github produces identical error messages on my system as commented in the example below

Using GDAL 3.4.2 & PROJ 8.2.1. raster 5.3.5-29 and terra 1.6.7 both work as expected.

Happy to provide further info / run tests

Paul

rm(list=ls())

sessionInfo()
## R version 4.2.1 (2022-06-23)
## Platform: x86_64-suse-linux-gnu (64-bit)
## Running under: openSUSE Tumbleweed

## Matrix products: default
## BLAS:   /usr/lib64/R/lib/libRblas.so
## LAPACK: /usr/lib64/R/lib/libRlapack.so

## locale:
##  [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C              
##  [3] LC_TIME=en_GB.UTF-8        LC_COLLATE=en_GB.UTF-8    
##  [5] LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_GB.UTF-8   
##  [7] LC_PAPER=en_GB.UTF-8       LC_NAME=C                 
##  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
## [11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C       

## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     

## loaded via a namespace (and not attached):
## [1] compiler_4.2.1 tools_4.2.1   

packageVersion("raster") # 3.6.0
packageVersion("terra") # 1.6.7

terra::gdal() # 3.4.2
## sessionInfo() ## see what terra has added to the namespace

## create and write a raster
r <-  raster::raster(ncols=3, nrows=3)
r[] <- 1:9
## sessionInfo() ## see what raster has added to the namespace

raster::writeRaster(r,"r.tif") ## Fails - Error: [write] unknown option(s): progressbar
raster::writeRaster(r,"r.rst") ## Fails - Error: [write] unknown option(s): progressbar
raster::writeRaster(r,"r.grd") ## OK

terra::writeRaster(terra::rast(r),"rt.tif")

## read in 
rr <- raster::raster("rt.tif") ## Fails -
## Error in .rasterObjectFromFile(x, band = band, objecttype = "RasterLayer",  : 
##  Cannot create a RasterLayer object from this file.
rr <- raster::raster("r.grd") ## OK

To use the current development version of "raster" you need to first install the development version of "terra"

Thanks - it worked