Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9156641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:49:08+00:00 2026-06-17T12:49:08+00:00

I have experiencing a weird problem with the ‘plot’ function of the ‘raster’ package.

  • 0

I have experiencing a weird problem with the ‘plot’ function of the ‘raster’ package.

library(raster)
ras <- raster(ncol=10, nrow=10)

EDIT

values(ras) <- runif(ncell(ras))

END EDIT

plot(ras)

Erreur dans as.double(y) : 
cannot coerce type 'S4' to vector of type 'double'

For what I have read on the net, this error depends on the user, and probably depends on the loaded packages. In my case, the problem comes from the fact that r uses the standard ‘plot’ method from the ‘graphics’ package, when it should use the specific ‘raster’ method since ‘ras’ is a rasterLayer object. However, for a reason I do not understand, ‘plot’ is not imported in the ‘raster’ namespace, while all the other functions are.

> raster::plot
Erreur : 'plot' n'est pas un objet exporté depuis 'namespace:raster'

To be compared with :

raster::persp
standardGeneric for "persp" defined from package "graphics"
function (x, ...) 
standardGeneric("persp")
<environment: 0x0cd9eb80>
Methods may be defined for arguments: x
Use  showMethods("persp")  for currently available ones.

Since I do not completely understand how namespaces behave, I am looking for your help ! Is this kind of situation familiar for you, and do you have a way to solve it ? In the meantime, do you know a function to display the content of a namespace (so I could check the content of the raster namespace step by step) ?

PS: I am using R 2.15.2 with RStudio, many packages loaded but all are up to date.

sessionInfo()
R version 2.15.0 (2012-03-30)
Platform: i386-pc-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=French_Belgium.1252  LC_CTYPE=French_Belgium.1252          LC_MONETARY=French_Belgium.1252 LC_NUMERIC=C                   
[5] LC_TIME=French_Belgium.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] raster_2.0-41 sp_1.0-5     

loaded via a namespace (and not attached):
 [1] grid_2.15.0      hexbin_1.26.0    intervals_0.13.3 lattice_0.20-6   rgdal_0.8-4      spacetime_1.0-3  spam_0.29-2      tools_2.15.0    
 [9] xts_0.9-2        zoo_1.7-9             

Thanks you,

François

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T12:49:09+00:00Added an answer on June 17, 2026 at 12:49 pm

    Using this you get all the list of object of package raster

    basevals <- ls(pos="package:raster") 
    

    for example

       which(basevals == 'persp')  ## function persp shows up because it is the exported generic.
       141
       which(basevals == 'plot')   ## no function plot
       integer(0)
    

    No when I do this , it works for me:

    library(raster)
    r <- raster(ncol=10, nrow=10)
    values(r) <- runif(ncell(r))
    plot(r, main='Raster with 100 cells')
    

    So There is certainly a plot method here. It is not in the previous list “basevals” beacuse it is an S4 method.

    To get the plot method of raster package , try this :

     getMethod('plot',signature=signature(x='Raster', y='ANY'))
    

    or more efficiently using

    findMethods("plot", "package:raster"). 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am experiencing a very weird problem: In WPF I have a tabControl which
I'm experiencing a (for me) very weird problem in Python. I have a class
I'm experiencing a weird problem with C today. Have a quick look at this
I have been experiencing a weird problem that I can't find a solution to.
I am experiencing some problem on UTF-8 Encoding. I have a CSV file and
I have a Windows Server 2003 64-Bit VPS, and I'm experiencing a problem with
I'm experiencing a weird problem with a SQL login. When I connect to the
I'm experiencing a weird problem which I hope someone in here may be able
Hi I'm experiencing a super weird problem. Whenever I post links to my website
I am experiencing something weird and have a workaround already, but I don't think

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.