1

I am trying to create a background land mask for my data. All of the questions I've seen are for CDO, which I cannot get to load into my R Studio (package ‘cdo’ is not available (for R version 4.0.2)). I am looking at shellfish data where the points are very close to land but only the ocean points are relevant.

I am currently trying to do this code:

background <- dismo::randomPoints(
  mask = mask, # provides resolution
  n=1036800, #number of random points
  ext = geographic.extent, #spatially restricts sampling
  extf = 1.25 #expands the sampling by 25% 
)

But I receive this error

Error in (function (classes, fdef, mtable)  : 
  unable to find an inherited method for function ‘nlayers’ for signature ‘"standardGeneric"’

I have tried to add specific libraries like library("conflicted") or require(dplyr) or even change the way I have been doing land masks altogether and have not found a solution.

zephryl
  • 14,633
  • 3
  • 11
  • 30
amerray
  • 11
  • 1
  • `nlayers` is a function of package {raster}. Maybe `update.packages('raster')` helps. Or you give package {terra} a try, which has been mentioned as the successor of {raster} on SO a couple of times: https://rspatial.org/terra/pkg/1-introduction.html. Mind that I've only basic experience in spatial analysis with R though ;-) –  Mar 30 '22 at 11:10
  • Are you in Linux or Windows? As I see it you first build [CDO](https://code.mpimet.mpg.de/projects/cdo/) and [NCO](http://nco.sourceforge.net/) on your system, then can use, [ClimateOperators](https://github.com/markpayneatwork/ClimateOperators)...if you are on Windows, it will be harder to do a build. Second the suggestion to both update `raster` and `terra`. – Chris Mar 30 '22 at 13:34
  • If, while building `CDO` you run into `./lib/yac/utils.h:73:10: fatal error: 'core/ppm_xfuncs.h' file not found`, see [fatal error:](https://code.mpimet.mpg.de/boards/1/topics/12178?r=12202), with solution at bottom, editing file `/cdo-2.0.5/src/grid_point_search.cc` as suggested. By that point you've skipped past Ralf's helpful suggestion that such pain can be avoided by downloading a binary. Note to self. – Chris Mar 30 '22 at 20:35

0 Answers0