R Under development (unstable) (2024-07-13 r86895 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > suppressPackageStartupMessages(library(stars)) > #suppressPackageStartupMessages(library(lwgeom)) > geomatrix = system.file("tif/geomatrix.tif", package = "stars") > (x = read_stars(geomatrix)) stars object with 2 dimensions and 1 attribute attribute(s): Min. 1st Qu. Median Mean 3rd Qu. Max. geomatrix.tif 74 107 123 126.765 132 255 dimension(s): from to offset delta refsys point x/y x 1 20 1841002 1.5 WGS 84 / UTM zone 11N TRUE [x] y 1 20 1144003 -1.5 WGS 84 / UTM zone 11N TRUE [y] sheared raster with parameters: -5 -5 > new = st_crs(4326) > y = st_transform(x, new) > plot(st_transform(st_as_sfc(st_bbox(x)), new), col = NA, border = 'red') > plot(st_as_sfc(y, as_points=FALSE), col = NA, border = 'green', axes = TRUE, add = TRUE) > image(y, add = TRUE) > plot(st_as_sfc(y, as_points=TRUE), pch=3, cex=.5, col = 'blue', add = TRUE) > plot(st_transform(st_as_sfc(x, as_points=FALSE), new), add = TRUE) > > tif = system.file("tif/L7_ETMs.tif", package = "stars") > x = read_stars(tif)[,1:10,1:10,1:3] > x_ = st_transform(x, st_crs(4326)) > ## IGNORE_RDIFF_BEGIN > if (require(lwgeom, quietly = TRUE)) { + x__ = st_transform_proj(x, st_crs(4326)$proj4string) + st_crs(x_) = st_crs(x__) + print(all.equal(x_,x__)) + + # x__ = st_transform(x, x_) #now in st_warp + # all.equal(x_, x__) + + x = st_xy2sfc(x, as_points = FALSE) + (x_ = st_transform(x, st_crs(4326))) + (x__ = st_transform_proj(x, st_crs(4326))) + print(all.equal(x_,x__,check.attributes = FALSE)) + } Linking to liblwgeom 3.0.0beta1 r16016, GEOS 3.12.1, PROJ 9.3.1 Attaching package: 'lwgeom' The following object is masked from 'package:sf': st_perimeter [1] TRUE [1] TRUE > ## IGNORE_RDIFF_END > > # nothing to transform: now errs: > try(st_transform(st_as_stars(list(m = matrix(1,10,10))), st_crs(4326))) Error in st_transform.stars(st_as_stars(list(m = matrix(1, 10, 10))), : !is.na(st_crs(x)) is not TRUE > try(st_transform_proj(st_as_stars(list(m = matrix(1,10,10))), st_crs(4326))) Error in st_transform_proj.stars(st_as_stars(list(m = matrix(1, 10, 10))), : !is.na(st_crs(x)) is not TRUE > > proc.time() user system elapsed 0.82 0.12 0.92