You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed that expansion of a filename containing ~ does not work for writeVector()
When writing vector, creation fails with e.g. Warning: Failed to create file ~/test\lux.shp: No such file or directory (GDAL error 1). Path expansion appears to work for read of vector and read/write of raster.
library(terra)
#> terra 1.7.19x<- vect(system.file("ex", "lux.shp", package="terra"))
y<- rast(system.file("ex", "elev.tif", package="terra"))
dir.create("~/test", showWarnings=FALSE)
# doesnt work
writeVector(x, "~/test/lux.shp")
#> Warning: Failed to create file ~/test\lux.shp: No such file or directory (GDAL#> error 1)#> Error: [writeVector] Layer creation failed# works
writeVector(x, path.expand("~/test/lux.shp"))
# works
vect("~/test/lux.shp")
#> class : SpatVector #> geometry : polygons #> dimensions : 12, 6 (geometries, attributes)#> extent : 5.74414, 6.528252, 49.44781, 50.18162 (xmin, xmax, ymin, ymax)#> source : lux.shp#> coord. ref. : lon/lat WGS 84 (EPSG:4326) #> names : ID_1 NAME_1 ID_2 NAME_2 AREA POP#> type : <num> <chr> <num> <chr> <num> <int>#> values : 1 Diekirch 1 Clervaux 312 18081#> 1 Diekirch 2 Diekirch 218 32543#> 1 Diekirch 3 Redange 259 18664# works
writeRaster(y, "~/test/elev.tif")
# works
rast("~/test/elev.tif")
#> class : SpatRaster #> dimensions : 90, 95, 1 (nrow, ncol, nlyr)#> resolution : 0.008333333, 0.008333333 (x, y)#> extent : 5.741667, 6.533333, 49.44167, 50.19167 (xmin, xmax, ymin, ymax)#> coord. ref. : lon/lat WGS 84 (EPSG:4326) #> source : elev.tif #> name : elevation #> min value : 141 #> max value : 547
unlink("~/test", recursive=TRUE)
The text was updated successfully, but these errors were encountered:
I noticed that expansion of a
filename
containing~
does not work forwriteVector()
When writing vector, creation fails with e.g.
Warning: Failed to create file ~/test\lux.shp: No such file or directory (GDAL error 1)
. Path expansion appears to work for read of vector and read/write of raster.The text was updated successfully, but these errors were encountered: