0

i am using terra::raster 0.9-1 and, specifically terra::values and the xyz function in terra::rast, but i keep encountering the following

Error in x@ptr$geometry(nlyrs) : could not find valid method

> sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
other attached packages:
 [1] terra_0.9-1       gdalUtils_2.0.3.2 geosphere_1.5-10  data.table_1.13.0 ggplot2_3.3.2     dplyr_1.0.2      
 [9] rgdal_1.5-16      rgeos_0.5-3       stringr_1.4.0     raster_3.3-13     sp_1.4-4          devtools_2.3.1

# dummy XYZ data
m_xyz <- as.matrix(expand.grid(seq(0.5,999.5,1),seq(0.5,999.5,1)))
m_xyz <- cbind(m_xyz, sample(1:10,1000^2,replace=T))

# coerce to rast (used to be raster::rasterfromXYZ)
rast(m_xyz,type="xyz")
Error in x@ptr$geometry(nlyrs) : could not find valid method

ok, ignore that and just create a rast and try to populate

rBNG <- rast(xmin = 0, xmax = 1000, ymin = 0, ymax = 1000, resolution = 1, crs = "epsg:27700", vals = NA)

# add some values
values(rBNG) <- sample(1:10,ncell(rBNG), replace = T)
Error in x@ptr$geometry(nlyrs) : could not find valid method

rBNG[] <- sample(1:10,ncell(rBNG), replace = T)
Error in x@ptr$geometry(nlyrs) : could not find valid method

i am new to terra, i have moved to sf and stars and now terra is the next step, perhaps there's just something simple i am not understanding

Loading required package: sp
rgdal: version: 1.5-16, (SVN revision 1050)
Geospatial Data Abstraction Library extensions to R successfully loaded
Loaded GDAL runtime: GDAL 3.0.4, released 2020/01/28
Path to GDAL shared files: C:/Users/xxxx/Documents/R/win-library/4.0/rgdal/gdal
GDAL binary built with GEOS: TRUE 
Loaded PROJ runtime: Rel. 6.3.1, February 10th, 2020, [PJ_VERSION: 631]
Path to PROJ shared files: C:/Users/xxxxx/Documents/R/win-library/4.0/rgdal/proj
Linking to sp version:1.4-2
To mute warnings of possible GDAL/OSR exportToProj4() degradation,
use options("rgdal_show_exportToProj4_warnings"="none") before loading rgdal.

Attaching package: ‘rgdal’

The following object is masked from ‘package:terra’:

    project

Warning message:
package ‘sp’ was built under R version 4.0.3 
3
  • You should revert to the CRAN version as it is currently "stable" and the GitHub version is failing in its build. This is why it is not always desirable to use the development version. To revert, you can just open a fresh R session and use install.packages("terra"). – Jeffrey Evans Oct 29 '20 at 17:57
  • thank you, the stable version does indeed work. – Sam Oct 30 '20 at 7:00
  • you were out of luck. The github version had this bug for about 12 hours... – Robert Hijmans Nov 18 '20 at 0:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.