Hi, I think you need to check the order of your arguments to rasterize(). See the documentation with ?rasterize and compare to what you did below.
Cheers, Ben > On Apr 30, 2016, at 9:55 AM, Ogbos Okike <giftedlife2...@gmail.com> wrote: > > Dear All, > Thanks for your inputs. I did replace pointsToRaster () with > raster::rasterize(). Below is part of my script. > > But I got another error: > Error in (function (classes, fdef, mtable) : > unable to find an inherited method for function ‘rasterize’ for > signature ‘"RasterLayer", "matrix"’ > > Thank you for more inputs. > Ogbos > > k<-read.table("Lat05w3.txt") > colnames(k)<-c("y","x") > xy<-cbind(k$x,k$y) > library(raster) > r<-raster() > #library(sp) > pr<-raster::rasterize(r,xy) > > #pr<-pointsToRaster(r,xy) > > library(maps) > w = map("world") > wc = cbind(w$x, w$y) > wc=wc[!is.na(wc[,1]),] > write.table(wc, file = "my.fileb", sep=" ",row=FALSE,col=FALSE) > my<-read.table("my.out",col.names=c("a","b")) > rena = function(X,Z){ > Y=rep(NA,length(X)) > Y[!is.na(X)]=Z > Y > } > > > > > On 4/30/16, Ben Tupper <btup...@bigelow.org> wrote: >> Hi, >> >> A terrific resource for this type of issue (and pretty much anything related >> to R) is http://rseek.org/ I'm sure I use it at least daily. Check out >> ... >> >> http://rseek.org/?q=pointsToRaster >> >> The first hit is about pointsToRaster() - it has been replaced by >> raster::rasterize() >> >> Cheers, >> Ben >> >>> On Apr 30, 2016, at 4:28 AM, Ogbos Okike <giftedlife2...@gmail.com> >>> wrote: >>> >>> Dear All, >>> I have a script that draws longitude and latitude of lightning >>> occurrence. This script was running fine before. But when I changed my >>> system and do a fresh install on another laptop, this error persist. >>> source("script") >>> Error in eval(expr, envir, enclos) : >>> could not find function "pointsToRaster" >>> >>> I have tried to see if there is any other package I need to install >>> to take of the problem, I could not see. Already, when I installed >>> raster, it installed its dependencies such as sp. >>> Can any body please bail me out. >>> >>> Thanks >>> Ogbos >>> >>> ______________________________________________ >>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >>> https://stat.ethz.ch/mailman/listinfo/r-help >>> PLEASE do read the posting guide >>> http://www.R-project.org/posting-guide.html >>> and provide commented, minimal, self-contained, reproducible code. >> >> Ben Tupper >> Bigelow Laboratory for Ocean Sciences >> 60 Bigelow Drive, P.O. Box 380 >> East Boothbay, Maine 04544 >> http://www.bigelow.org >> >> Ben Tupper Bigelow Laboratory for Ocean Sciences 60 Bigelow Drive, P.O. Box 380 East Boothbay, Maine 04544 http://www.bigelow.org ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.